Skip to content

Commit f84df0a

Browse files
committed
tag latest
1 parent 82f6f08 commit f84df0a

File tree

3 files changed

+75
-8
lines changed

3 files changed

+75
-8
lines changed

.github/workflows/pull_request.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,46 @@ env:
88
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
99

1010
jobs:
11+
get_issue_number_and_commit_id:
12+
runs-on: ubuntu-22.04
13+
outputs:
14+
issue_number: ${{ steps.get_issue_number.outputs.result }}
15+
version: ${{ steps.get_issue_number.outputs.version_number }}
16+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
17+
sha_short: ${{ steps.commit_id.outputs.sha_short }}
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v5
22+
with:
23+
ref: ${{ env.BRANCH_NAME }}
24+
25+
- uses: actions/github-script@v8
26+
name: get issue number
27+
id: get_issue_number
28+
with:
29+
script: |
30+
if (context.issue.number) {
31+
// Return issue number if present
32+
return context.issue.number;
33+
} else {
34+
// Otherwise return issue number from commit
35+
return (
36+
await github.rest.repos.listPullRequestsAssociatedWithCommit({
37+
commit_sha: context.sha,
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
})
41+
).data[0].number;
42+
}
43+
result-encoding: string
44+
- name: Get Commit ID
45+
id: commit_id
46+
run: |
47+
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
48+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
49+
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
50+
1151
pr_title_format_check:
1252
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/pr_title_check.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99
1353
get_asdf_version:
@@ -29,11 +69,12 @@ jobs:
2969
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
3070
quality_checks:
3171
uses: ./.github/workflows/quality-checks.yml
32-
needs: [get_asdf_version]
72+
needs: [get_asdf_version, get_issue_number_and_commit_id]
3373
with:
3474
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
3575
dev_container_ecr: dev-container-quality-checks
36-
dev_container_image_tag: latest
76+
dev_container_image_tag: PR-${{ needs.get_issue_number_and_commit_id.outputs.issue_number }}-${{ needs.get_issue_number_and_commit_id.outputs.sha_short }}
77+
tag_latest: false
3778
secrets:
3879
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3980
PUSH_IMAGE_ROLE: ${{ secrets.PUSH_IMAGE_ROLE }}

.github/workflows/quality-checks.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ on:
2828
dev_container_ecr:
2929
type: string
3030
description: "The name of the ECR repository to push the dev container image to."
31-
required: false
31+
required: true
3232
dev_container_image_tag:
3333
type: string
3434
description: "The tag to use for the dev container image."
35-
required: false
35+
required: true
36+
tag_latest:
37+
type: boolean
38+
description: "If true, the action will also tag the dev container image as 'latest' in ECR."
39+
required: true
3640
jobs:
3741
quality_checks:
3842
runs-on: ubuntu-22.04
@@ -370,7 +374,6 @@ jobs:
370374
permissions:
371375
id-token: write
372376
runs-on: ubuntu-22.04
373-
if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }}
374377
steps:
375378
- name: Checkout code
376379
uses: actions/checkout@v5
@@ -419,7 +422,6 @@ jobs:
419422
permissions:
420423
id-token: write
421424
runs-on: ubuntu-22.04-arm
422-
if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }}
423425
steps:
424426
- name: Checkout code
425427
uses: actions/checkout@v5
@@ -498,13 +500,16 @@ jobs:
498500
run: |
499501
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com
500502
501-
- name: Create and push multi-architecture manifest
503+
- name: Create and push multi-architecture manifest for tag
502504
run: |
503505
# Create manifest list combining both architectures
504506
docker buildx imagetools create -t ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }} \
505507
${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64 \
506508
${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-arm64
507509
510+
- name: Create and push multi-architecture manifest for latest tag
511+
if: ${{ inputs.tag_latest == true }}
512+
run: |
508513
# Also create latest tag
509514
docker buildx imagetools create -t ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:latest \
510515
${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64 \

.github/workflows/release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ env:
88
BRANCH_NAME: ${{ github.event.ref.BRANCH_NAME }}
99

1010
jobs:
11+
get_commit_id:
12+
runs-on: ubuntu-22.04
13+
outputs:
14+
commit_id: ${{ steps.commit_id.outputs.commit_id }}
15+
sha_short: ${{ steps.commit_id.outputs.sha_short }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
with:
21+
ref: ${{ env.BRANCH_NAME }}
22+
23+
- name: Get Commit ID
24+
id: commit_id
25+
run: |
26+
# echo "commit_id=${{ github.sha }}" >> "$GITHUB_ENV"
27+
echo "commit_id=${{ github.sha }}" >> "$GITHUB_OUTPUT"
28+
echo "sha_short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
1129
get_asdf_version:
1230
runs-on: ubuntu-22.04
1331
outputs:
@@ -26,10 +44,13 @@ jobs:
2644
TAG_FORMAT=$(yq '.TAG_FORMAT' .github/config/settings.yml)
2745
echo "TAG_FORMAT=$TAG_FORMAT" >> "$GITHUB_OUTPUT"
2846
quality_checks:
29-
needs: [get_asdf_version]
47+
needs: [get_asdf_version, get_commit_id]
3048
uses: ./.github/workflows/quality-checks.yml
3149
with:
3250
asdfVersion: ${{ needs.get_asdf_version.outputs.asdf_version }}
51+
tag_latest: true
52+
dev_container_ecr: dev-container-quality-checks
53+
dev_container_image_tag: release-${{ needs.get_commit_id.outputs.sha_short }}
3354
secrets:
3455
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3556
PUSH_IMAGE_ROLE: ${{ secrets.PUSH_IMAGE_ROLE }}

0 commit comments

Comments
 (0)