8
8
type : string
9
9
required : true
10
10
11
+ permissions :
12
+ contents : read # Changelog commit operations use service account PAT
13
+
11
14
env :
12
15
CI_COMMIT_AUTHOR : hc-github-team-tf-provider-devex
13
16
CI_COMMIT_EMAIL :
[email protected]
14
17
15
- permissions :
16
- contents : write
17
-
18
18
jobs :
19
19
changelog-version :
20
20
runs-on : ubuntu-latest
23
23
steps :
24
24
- id : changelog-version
25
25
run : echo "version=$(echo "${{ inputs.versionNumber }}" | cut -c 2-)" >> "$GITHUB_OUTPUT"
26
+
26
27
changelog :
27
28
needs : changelog-version
28
29
runs-on : ubuntu-latest
@@ -31,27 +32,30 @@ jobs:
31
32
uses : actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
32
33
with :
33
34
fetch-depth : 0
35
+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
36
+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
37
+ persist-credentials : false
38
+
34
39
- name : Batch changes
35
40
uses : miniscruff/changie-action@b6d52c80deb236a5b548f8774cd5a18b87da9e9a # v1.0.1
36
41
with :
37
42
version : latest
38
43
args : batch ${{ needs.changelog-version.outputs.version }}
39
- env :
40
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44
+
41
45
- name : Merge changes
42
46
uses : miniscruff/changie-action@b6d52c80deb236a5b548f8774cd5a18b87da9e9a # v1.0.1
43
47
with :
44
48
version : latest
45
49
args : merge
46
- env :
47
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
50
+
48
51
- name : Git push changelog
49
52
run : |
50
53
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
51
54
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
52
55
git add .
53
56
git commit -a -m "Update changelog"
54
- git push
57
+ git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
58
+
55
59
release-tag :
56
60
needs : changelog
57
61
runs-on : ubuntu-latest
@@ -60,13 +64,21 @@ jobs:
60
64
uses : actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
61
65
with :
62
66
fetch-depth : 0
67
+ # Default input is the SHA that initially triggered the workflow. As we created a new commit in the previous job,
68
+ # to ensure we get the latest commit we use the ref for checkout: 'refs/heads/<branch_name>'
69
+ ref : ${{ github.ref }}
70
+ # Avoid persisting GITHUB_TOKEN credentials as they take priority over our service account PAT for `git push` operations
71
+ # More details: https://github.com/actions/checkout/blob/b4626ce19ce1106186ddf9bb20e706842f11a7c3/adrs/0153-checkout-v2.md#persist-credentials
72
+ persist-credentials : false
73
+
63
74
- name : Git push release tag
64
75
run : |
65
76
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
66
77
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
67
- git pull
78
+
68
79
git tag "${{ inputs.versionNumber }}"
69
- git push origin "${{ inputs.versionNumber }}"
80
+ git push "https://${{ env.CI_COMMIT_AUTHOR }}:${{ secrets.TF_DEVEX_COMMIT_GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "${{ inputs.versionNumber }}"
81
+
70
82
release-notes :
71
83
needs : [ changelog-version, changelog, release-tag ]
72
84
runs-on : ubuntu-latest
@@ -75,18 +87,23 @@ jobs:
75
87
with :
76
88
ref : ${{ inputs.versionNumber }}
77
89
fetch-depth : 0
90
+
78
91
- name : Generate Release Notes
79
92
run : |
80
93
cd .changes
81
94
sed -e "1{/# /d;}" -e "2{/^$/d;}" ${{ needs.changelog-version.outputs.version }}.md > release-notes.txt
95
+
82
96
- uses : actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
83
97
with :
84
98
name : release-notes
85
99
path : ./.changes/release-notes.txt
86
100
retention-days : 1
101
+
87
102
terraform-provider-release :
88
103
name : ' Terraform Provider Release'
89
104
needs : [ release-notes ]
105
+ permissions :
106
+ contents : write # Needed for goreleaser to create GitHub release
90
107
uses : hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml@01981baad5d35ce2342924e60ae91cf69fe31fd0 # v2.3.0
91
108
secrets :
92
109
hc-releases-key-prod : ' ${{ secrets.HC_RELEASES_KEY_PROD }}'
0 commit comments