Skip to content

Commit 8c2c53c

Browse files
committed
apply latest tag
1 parent ddc04e4 commit 8c2c53c

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

.github/workflows/pull_request.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ jobs:
7777
secrets:
7878
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7979
PUSH_IMAGE_ROLE: ${{ secrets.PUSH_IMAGE_ROLE }}
80+
tag_latest_dev_container:
81+
needs: [quality_checks, get_issue_number_and_commit_id]
82+
uses: ./.github/workflows/tag_latest_dev_container.yml
83+
with:
84+
dev_container_ecr: dev-container-quality-checks
85+
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 }}
86+
version_tag_to_apply: FooBar
87+
secrets:
88+
PUSH_IMAGE_ROLE: ${{ secrets.PUSH_IMAGE_ROLE }}
8089
tag_release:
8190
needs: [quality_checks, get_asdf_version]
8291
uses: NHSDigital/eps-workflow-semantic-release/.github/workflows/tag-release.yml@f80157cecce288dd175e61b477a1d2dbe9c88b99

.github/workflows/quality-checks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,9 @@ jobs:
467467
id-token: write
468468
runs-on: ubuntu-22.04
469469
needs: [build_dev_container_x64, build_dev_container_arm64]
470-
if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }}
471470
steps:
472471
- name: Set up Docker Buildx
473-
uses: docker/setup-buildx-action@v3
472+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
474473

475474
- name: Configure AWS Credentials
476475
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Tag Latest Dev Container
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
PUSH_IMAGE_ROLE:
7+
required: true
8+
inputs:
9+
dev_container_ecr:
10+
type: string
11+
description: "The name of the ECR repository to push the dev container image to."
12+
required: true
13+
dev_container_image_tag:
14+
type: string
15+
description: "The tag to use for the dev container image."
16+
required: true
17+
version_tag_to_apply:
18+
type: string
19+
description: "The version tag to apply to the latest dev container image."
20+
required: true
21+
jobs:
22+
create_multi_arch_manifest:
23+
permissions:
24+
id-token: write
25+
runs-on: ubuntu-22.04
26+
steps:
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
29+
30+
- name: Configure AWS Credentials
31+
uses: aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
32+
with:
33+
aws-region: eu-west-2
34+
role-to-assume: ${{ secrets.PUSH_IMAGE_ROLE }}
35+
role-session-name: multi-arch-manifest
36+
output-credentials: true
37+
38+
- name: Retrieve AWS Account ID
39+
id: retrieve-deploy-account-id
40+
run: |
41+
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
42+
echo "account_id=$ACCOUNT_ID" >> "$GITHUB_OUTPUT"
43+
44+
- name: Login to Amazon ECR
45+
run: |
46+
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
47+
48+
- name: Create and push multi-architecture manifest for tag
49+
env:
50+
ECR_REPOSITORY: ${{ inputs.dev_container_ecr }}
51+
IMAGE_TAG: ${{ inputs.dev_container_image_tag }}
52+
ACCOUNT_ID: ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
53+
VERSION_TAG_TO_APPLY: ${{ inputs.version_tag_to_apply }}
54+
run: |
55+
# Create manifest list combining both architectures
56+
docker buildx imagetools create -t "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest" \
57+
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64" \
58+
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
59+
docker buildx imagetools create -t "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${VERSION_TAG_TO_APPLY}" \
60+
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64" \
61+
"${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
62+
63+
- name: Verify multi-architecture manifest
64+
env:
65+
ECR_REPOSITORY: ${{ inputs.dev_container_ecr }}
66+
IMAGE_TAG: ${{ inputs.dev_container_image_tag }}
67+
ACCOUNT_ID: ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
68+
run: |
69+
echo "=== Verifying multi-architecture manifest ==="
70+
docker buildx imagetools inspect "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:latest"

0 commit comments

Comments
 (0)