2525 default : " dev_container_build"
2626
2727jobs :
28- build_image_amd64 :
28+ build_image :
2929 permissions :
3030 id-token : write
31- runs-on : ubuntu-22.04
31+ runs-on : ${{ matrix.runner }}
32+ strategy :
33+ matrix :
34+ include :
35+ - arch : amd64
36+ runner : ubuntu-22.04
37+ - arch : arm64
38+ runner : ubuntu-22.04-arm
3239 steps :
3340 - name : Checkout code
3441 uses : actions/checkout@v5
3744
3845 - name : Build container
3946 run : |
40- docker build -f "${DOCKER_FILE}" -t amd64 -image .
47+ docker build -f "${DOCKER_FILE}" -t ${{ matrix.arch }} -image .
4148 env :
4249 DOCKER_FILE : ${{ inputs.docker_file }}
4350
4754 with :
4855 aws-region : eu-west-2
4956 role-to-assume : ${{ secrets.PUSH_IMAGE_ROLE }}
50- role-session-name : dev-container-build-amd64
57+ role-session-name : dev-container-build-${{ matrix.arch }}
5158 output-credentials : true
5259
5360 - name : Retrieve AWS Account ID
@@ -60,74 +67,20 @@ jobs:
6067 run : |
6168 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
6269
63- - name : Push amd64 image to Amazon ECR
70+ - name : Push ${{ matrix.arch }} image to Amazon ECR
6471 env :
6572 ECR_REPOSITORY : ${{ inputs.container_ecr }}
6673 IMAGE_TAG : ${{ inputs.container_image_tag }}
6774 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
75+ ARCH : ${{ matrix.arch }}
6876 run : |
69- docker tag "amd64-image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64"
70- docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64"
71-
72- - name : Check dev container scan results
73- env :
74- REPOSITORY_NAME : ${{ inputs.container_ecr }}
75- IMAGE_TAG : ${{ inputs.container_image_tag }}-amd64
76- ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
77- SCRIPT_TAG : ${{ inputs.check_ecr_image_scan_results_script_tag }}
78- run : |
79- curl -L "https://raw.githubusercontent.com/NHSDigital/eps-common-workflows/refs/heads/${SCRIPT_TAG}/.github/scripts/check_ecr_image_scan_results.sh" -o /tmp/check_ecr_image_scan_results.sh
80- chmod +x /tmp/check_ecr_image_scan_results.sh
81- sleep 30
82- /tmp/check_ecr_image_scan_results.sh
83-
84- build_image_arm64 :
85- permissions :
86- id-token : write
87- runs-on : ubuntu-22.04-arm
88- steps :
89- - name : Checkout code
90- uses : actions/checkout@v5
91- with :
92- fetch-depth : 0
93-
94- - name : Build container
95- run : |
96- docker build -f "${DOCKER_FILE}" -t arm64-image .
97- env :
98- DOCKER_FILE : ${{ inputs.docker_file }}
99-
100- - name : Configure AWS Credentials
101- uses : aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
102- id : connect-aws-deploy
103- with :
104- aws-region : eu-west-2
105- role-to-assume : ${{ secrets.PUSH_IMAGE_ROLE }}
106- role-session-name : dev-container-build-arm64
107- output-credentials : true
108-
109- - name : Retrieve AWS Account ID
110- id : retrieve-deploy-account-id
111- run : |
112- ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
113- echo "account_id=$ACCOUNT_ID" >> "$GITHUB_OUTPUT"
114-
115- - name : Login to Amazon ECR
116- run : |
117- 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
77+ docker tag "${ARCH}-image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-${ARCH}"
78+ docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-${ARCH}"
11879
119- - name : Push ARM64 image to Amazon ECR
120- env :
121- ECR_REPOSITORY : ${{ inputs.container_ecr }}
122- IMAGE_TAG : ${{ inputs.container_image_tag }}
123- ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
124- run : |
125- docker tag "arm64-image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
126- docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
12780 - name : Check dev container scan results
12881 env :
12982 REPOSITORY_NAME : ${{ inputs.container_ecr }}
130- IMAGE_TAG : ${{ inputs.container_image_tag }}-arm64
83+ IMAGE_TAG : ${{ inputs.container_image_tag }}-${{ matrix.arch }}
13184 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
13285 SCRIPT_TAG : ${{ inputs.check_ecr_image_scan_results_script_tag }}
13386 run : |
14093 permissions :
14194 id-token : write
14295 runs-on : ubuntu-22.04
143- needs : [build_image_amd64, build_image_arm64 ]
96+ needs : [build_image ]
14497 steps :
14598 - name : Set up Docker Buildx
14699 uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
0 commit comments