generated from deploymenttheory/Template
-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (92 loc) · 3.41 KB
/
create-version-and-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Create Version and Release
on:
workflow_call:
inputs:
source_environment:
required: true
type: string
target_environment:
required: true
type: string
config_directory:
required: true
type: string
debug:
required: false
type: boolean
default: false
outputs:
new_version:
description: "The new release version number"
value: ${{ jobs.create-version-and-release.outputs.new_version }}
config_hash:
description: "The new release configuration hash"
value: ${{ jobs.create-version-and-release.outputs.config_hash }}
jobs:
create-version-and-release:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.combine_version_hash.outputs.new_version }}
config_hash: ${{ steps.generate_hash.outputs.config_hash }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
ref: ${{ inputs.source_environment }}
- name: Harden Runner
uses: step-security/harden-runner@v2.10.3
with:
egress-policy: audit
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: '3.x'
- name: Determine release version
id: determine_version
run: |
python $GITHUB_WORKSPACE/workload/scripts/version_determinator.py '${{ inputs.config_directory }}'
- name: Generate release hash
id: generate_hash
run: |
python $GITHUB_WORKSPACE/workload/scripts/hash_generator.py '${{ inputs.config_directory }}'
- name: Combine version and hash
id: combine_version_hash
run: |
NEW_VERSION="${{ steps.determine_version.outputs.version }}-${{ steps.generate_hash.outputs.config_hash }}"
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo "CONFIG_HASH=${{ steps.generate_hash.outputs.config_hash }}" >> $GITHUB_ENV
- name: Display new release version
if: ${{ inputs.debug == 'true' }}
run: |
echo "New version: ${{ env.NEW_VERSION }}"
- name: Create and push new tag
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ env.NEW_VERSION }}
git push origin ${{ env.NEW_VERSION }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2.2.1
with:
tag_name: ${{ env.NEW_VERSION }}
name: ${{ env.NEW_VERSION }}
body: |
🚀 This release was manually triggered by @${{ github.actor }}.
🔄 Source: ${{ inputs.source_environment }}
🎯 Target: ${{ inputs.target_environment }}
🔒 TF Configuration File Hash: ${{ env.CONFIG_HASH }}
draft: false
prerelease: false
files: |
${{ inputs.config_directory }}/**/*.tf
README.md
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push release branch
id: create_release_branch
run: |
git checkout -b release-${{ env.NEW_VERSION }}-to-${{ inputs.target_environment }}
git push origin release-${{ env.NEW_VERSION }}-to-${{ inputs.target_environment }}