88 BRANCH_NAME : ${{ github.ref_name }}
99
1010jobs :
11- quality_checks :
12- uses :
NHSDigital/eps-workflow-quality-checks/.github/workflows/[email protected] 13- secrets :
14- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
15-
1611 get_commit_id :
1712 runs-on : ubuntu-22.04
1813 outputs :
1914 commit_id : ${{ steps.commit_id.outputs.commit_id }}
15+ sha_short : ${{ steps.commit_id.outputs.sha_short }}
16+
2017 steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v5
20+ with :
21+ ref : ${{ env.BRANCH_NAME }}
22+
2123 - name : Get Commit ID
2224 id : commit_id
2325 run : |
26+ # echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
2427 echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
25-
26- tag_release :
27- needs : quality_checks
28+ echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
29+ get_asdf_version :
2830 runs-on : ubuntu-22.04
2931 outputs :
30- version_tag : ${{steps.output_version_tag.outputs.VERSION_TAG}}
32+ asdf_version : ${{ steps.asdf-version.outputs.version }}
33+ tag_format : ${{ steps.load-config.outputs.TAG_FORMAT }}
3134 steps :
3235 - name : Checkout code
3336 uses : actions/checkout@v5
34- with :
35- ref : ${{ env.BRANCH_NAME }}
36- fetch-depth : 0
3737
38- # using git commit sha for version of action to ensure we have stable version
39- - name : Install asdf
40- uses : asdf-vm/actions/setup@1902764435ca0dd2f3388eea723a4f92a4eb8302
41- with :
42- asdf_branch : v0.14.1
43-
44- - name : Cache asdf
45- uses : actions/cache@v4
46- with :
47- path : |
48- ~/.asdf
49- key : ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }}
50- restore-keys : |
51- ${{ runner.os }}-asdf-
52-
53- - name : Install asdf dependencies in .tool-versions
54- uses : asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302
55- with :
56- asdf_branch : v0.14.1
57- env :
58- PYTHON_CONFIGURE_OPTS : --enable-shared
59-
60- - name : Setting up .npmrc
61- env :
62- NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38+ - name : Get asdf version
39+ id : asdf-version
40+ run : echo "version=$(awk '!/^#/ && NF {print $1; exit}' .tool-versions.asdf)" >> "$GITHUB_OUTPUT"
41+ - name : Load config value
42+ id : load-config
6343 run : |
64- echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> ~/.npmrc
65- echo "@NHSDigital:registry=https://npm.pkg.github.com" >> ~/.npmrc
66-
67- - name : Install node packages
68- run : |
69- make install-node
70-
71- - name : Set VERSION_TAG env var to be short git SHA and get next tag version
72- id : output_version_tag
73- run : |
74- VERSION_TAG=$(git rev-parse --short HEAD)
75- npx semantic-release --dry-run > semantic-release-output.log
76- NEXT_VERSION=$(grep -i 'The next release version is' semantic-release-output.log | sed -E 's/.* ([[:digit:].]+)$/\1/')
77- if [ -z "${NEXT_VERSION}" ]
78- then
79- echo "Could not get next tag. Here is the log from semantic-release"
80- cat semantic-release-output.log
81- exit 1
82- fi
83- tagFormat=$(node -e "const config=require('./release.config.js'); console.log(config.tagFormat)")
84- if [ "${tagFormat}" = "null" ]
85- then
86- tagFormat="v\${version}"
87- fi
88- # disabling shellcheck as replace does not work
89- # shellcheck disable=SC2001
90- VERSION_TAG=$(echo "$tagFormat" | sed "s/\${version}/$NEXT_VERSION/")
91- echo "## VERSION TAG : ${VERSION_TAG}" >> "$GITHUB_STEP_SUMMARY"
92- echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_OUTPUT"
93- echo "VERSION_TAG=${VERSION_TAG}" >> "$GITHUB_ENV"
94- env :
95- GITHUB_TOKEN : ${{ github.token }}
96-
97- - name : tag release
98- env :
99- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
100- run : |
101- npx semantic-release
102-
103- - name : Get release for editing
104- id : get_release
105- # version 1.2.4
106- uses : cardinalby/git-get-release-action@5172c3a026600b1d459b117738c605fabc9e4e44
107- env :
108- GITHUB_TOKEN : ${{ github.token }}
109- with :
110- tag : ${{ env.VERSION_TAG }}
44+ TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
45+ echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
46+ quality_checks :
47+ uses : NHSDigital/eps-workflow-quality-checks/.github/workflows/quality-checks.yml@4a6d03ad51516eddc448daf454805f85fe2025b9
48+ needs : [get_asdf_version, get_commit_id]
49+ with :
50+ asdfVersion : ${{ needs.get_asdf_version.outputs.asdf_version }}
51+ secrets :
52+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
11153
112- - name : Edit Release
113- # version 1.2.0
114- uses : irongut/EditRelease@ccf529ad26dddf9996e7dd0f24ca5da4ea507cc2
115- with :
116- token : ${{ secrets.GITHUB_TOKEN }}
117- id : ${{ steps.get_release.outputs.id }}
118- body : |
119- ## Info
120- [See code diff](${{ github.event.compare }})
121- [Release workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
122- It was initialized by [${{ github.event.sender.login }}](${{ github.event.sender.html_url }})
54+ tag_release :
55+ needs : [quality_checks, get_commit_id, get_asdf_version]
56+ uses : NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
57+ with :
58+ dry_run : false
59+ asdfVersion : ${{ needs.get_asdf_version.outputs.asdf_version }}
60+ branch_name : main
61+ publish_package : false
62+ tag_format : ${{ needs.get_asdf_version.outputs.tag_format }}
63+ secrets : inherit
12364
12465 package_code :
12566 needs : [tag_release, quality_checks, get_commit_id]
@@ -141,73 +82,49 @@ jobs:
14182 CDK_PUSH_IMAGE_ROLE : ${{ secrets.DEV_CDK_PUSH_IMAGE_ROLE }}
14283
14384 release_qa :
144- needs :
145- [
146- tag_release,
147- release_dev,
148- package_code,
149- get_commit_id,
150- ]
85+ needs : [tag_release, release_dev, package_code, get_commit_id]
15186 uses : ./.github/workflows/docker_image_upload.yml
15287 with :
153- AWS_ENVIRONMENT : qa
154- VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
155- COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
156- TAG_LATEST : true
157- DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
88+ AWS_ENVIRONMENT : qa
89+ VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
90+ COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
91+ TAG_LATEST : true
92+ DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
15893 secrets :
159- CDK_PUSH_IMAGE_ROLE : ${{ secrets.QA_CDK_PUSH_IMAGE_ROLE }}
160-
94+ CDK_PUSH_IMAGE_ROLE : ${{ secrets.QA_CDK_PUSH_IMAGE_ROLE }}
95+
16196 release_ref :
162- needs :
163- [
164- tag_release,
165- release_dev,
166- package_code,
167- get_commit_id,
168- ]
97+ needs : [tag_release, release_dev, package_code, get_commit_id]
16998 uses : ./.github/workflows/docker_image_upload.yml
17099 with :
171- AWS_ENVIRONMENT : ref
172- VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
173- COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
174- TAG_LATEST : true
175- DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
100+ AWS_ENVIRONMENT : ref
101+ VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
102+ COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
103+ TAG_LATEST : true
104+ DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
176105 secrets :
177- CDK_PUSH_IMAGE_ROLE : ${{ secrets.REF_CDK_PUSH_IMAGE_ROLE }}
178-
106+ CDK_PUSH_IMAGE_ROLE : ${{ secrets.REF_CDK_PUSH_IMAGE_ROLE }}
107+
179108 release_int :
180- needs :
181- [
182- tag_release,
183- release_qa,
184- package_code,
185- get_commit_id,
186- ]
109+ needs : [tag_release, release_qa, package_code, get_commit_id]
187110 uses : ./.github/workflows/docker_image_upload.yml
188111 with :
189- AWS_ENVIRONMENT : int
190- VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
191- COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
192- TAG_LATEST : true
193- DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
112+ AWS_ENVIRONMENT : int
113+ VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
114+ COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
115+ TAG_LATEST : true
116+ DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
194117 secrets :
195- CDK_PUSH_IMAGE_ROLE : ${{ secrets.INT_CDK_PUSH_IMAGE_ROLE }}
196-
118+ CDK_PUSH_IMAGE_ROLE : ${{ secrets.INT_CDK_PUSH_IMAGE_ROLE }}
119+
197120 release_prod :
198- needs :
199- [
200- tag_release,
201- release_int,
202- package_code,
203- get_commit_id,
204- ]
121+ needs : [tag_release, release_int, package_code, get_commit_id]
205122 uses : ./.github/workflows/docker_image_upload.yml
206123 with :
207- AWS_ENVIRONMENT : prod
208- VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
209- COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
210- TAG_LATEST : true
211- DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
124+ AWS_ENVIRONMENT : prod
125+ VERSION_NUMBER : ${{needs.tag_release.outputs.version_tag}}
126+ COMMIT_ID : ${{ needs.get_commit_id.outputs.commit_id }}
127+ TAG_LATEST : true
128+ DOCKER_IMAGE_TAG : ${{needs.tag_release.outputs.version_tag}}
212129 secrets :
213- CDK_PUSH_IMAGE_ROLE : ${{ secrets.PROD_CDK_PUSH_IMAGE_ROLE }}
130+ CDK_PUSH_IMAGE_ROLE : ${{ secrets.PROD_CDK_PUSH_IMAGE_ROLE }}
0 commit comments