1- name : Build nhsd git secrets
1+ name : Build and push docker image
22
33on :
44 workflow_call :
55 secrets :
6- SONAR_TOKEN :
7- required : false
86 PUSH_IMAGE_ROLE :
97 required : true
108 inputs :
11- git_secrets_container_ecr :
9+ container_ecr :
10+ type : string
11+ description : " The name of the ECR repository to push the container image to."
12+ required : true
13+ container_image_tag :
1214 type : string
13- description : " The name of the ECR repository to push the dev container image to ."
15+ description : " The tag to use for the container image."
1416 required : true
15- git_secrets_container_image_tag :
17+ docker_file :
1618 type : string
17- description : " The tag to use for the dev container image."
19+ description : " The Dockerfile to use for building the container image."
1820 required : true
21+ check_ecr_image_scan_results_script_tag :
22+ type : string
23+ description : " The tag to download check_ecr_image_scan_results.sh script."
24+ required : false
25+ default : " dev_container_build"
26+
1927jobs :
20- build_nhsd_git_secrets_x64 :
28+ build_image_amd64 :
2129 permissions :
2230 id-token : write
2331 runs-on : ubuntu-22.04
@@ -27,17 +35,19 @@ jobs:
2735 with :
2836 fetch-depth : 0
2937
30- - name : Build dev container
38+ - name : Build container
3139 run : |
32- docker build -f dockerfiles/nhsd-git-secrets.dockerfile -t nhsd-git-secrets-image .
40+ docker build -f "${DOCKER_FILE}" -t x64-image .
41+ env :
42+ DOCKER_FILE : ${{ inputs.docker_file }}
3343
3444 - name : Configure AWS Credentials
3545 uses : aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
3646 id : connect-aws-deploy
3747 with :
3848 aws-region : eu-west-2
3949 role-to-assume : ${{ secrets.PUSH_IMAGE_ROLE }}
40- role-session-name : dev-container-build-x64
50+ role-session-name : dev-container-build-amd64
4151 output-credentials : true
4252
4353 - name : Retrieve AWS Account ID
@@ -52,22 +62,26 @@ jobs:
5262
5363 - name : Push x64 image to Amazon ECR
5464 env :
55- ECR_REPOSITORY : ${{ inputs.git_secrets_container_ecr }}
56- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}
65+ ECR_REPOSITORY : ${{ inputs.container_ecr }}
66+ IMAGE_TAG : ${{ inputs.container_image_tag }}
5767 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
5868 run : |
59- docker tag "nhsd-git-secrets -image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64"
69+ docker tag "amd64 -image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64"
6070 docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-amd64"
71+
6172 - name : Check dev container scan results
6273 env :
63- REPOSITORY_NAME : ${{ inputs.git_secrets_container_ecr }}
64- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}-amd64
74+ REPOSITORY_NAME : ${{ inputs.container_ecr }}
75+ IMAGE_TAG : ${{ inputs.container_image_tag }}-amd64
6576 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
77+ SCRIPT_TAG : ${{ inputs.check_ecr_image_scan_results_script_tag }}
6678 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
6781 sleep 30
68- ./.github/scripts /check_ecr_image_scan_results.sh
82+ /tmp /check_ecr_image_scan_results.sh
6983
70- build_nhsd_git_secrets_arm64 :
84+ build_image_arm64 :
7185 permissions :
7286 id-token : write
7387 runs-on : ubuntu-22.04-arm
7791 with :
7892 fetch-depth : 0
7993
80- - name : Build dev container
94+ - name : Build container
8195 run : |
82- docker build -f dockerfiles/nhsd-git-secrets.dockerfile -t nhsd-git-secrets-image-arm .
96+ docker build -f "${DOCKER_FILE}" -t arm64-image .
97+ env :
98+ DOCKER_FILE : ${{ inputs.docker_file }}
8399
84100 - name : Configure AWS Credentials
85101 uses : aws-actions/configure-aws-credentials@00943011d9042930efac3dcd3a170e4273319bc8
@@ -102,27 +118,29 @@ jobs:
102118
103119 - name : Push ARM64 image to Amazon ECR
104120 env :
105- ECR_REPOSITORY : ${{ inputs.git_secrets_container_ecr }}
106- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}
121+ ECR_REPOSITORY : ${{ inputs.container_ecr }}
122+ IMAGE_TAG : ${{ inputs.container_image_tag }}
107123 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
108124 run : |
109- docker tag "nhsd-git-secrets- image-arm " "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
125+ docker tag "arm64- image" "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
110126 docker push "${ACCOUNT_ID}.dkr.ecr.eu-west-2.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}-arm64"
111127 - name : Check dev container scan results
112128 env :
113- REPOSITORY_NAME : ${{ inputs.git_secrets_container_ecr }}
114- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}-arm64
129+ REPOSITORY_NAME : ${{ inputs.container_ecr }}
130+ IMAGE_TAG : ${{ inputs.container_image_tag }}-arm64
115131 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
132+ SCRIPT_TAG : ${{ inputs.check_ecr_image_scan_results_script_tag }}
116133 run : |
117- # Wait a moment for ECR to process the new manifest
134+ 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
135+ chmod +x /tmp/check_ecr_image_scan_results.sh
118136 sleep 30
119- ./.github/scripts /check_ecr_image_scan_results.sh
137+ /tmp /check_ecr_image_scan_results.sh
120138
121139 create_multi_arch_manifest :
122140 permissions :
123141 id-token : write
124142 runs-on : ubuntu-22.04
125- needs : [build_nhsd_git_secrets_x64, build_nhsd_git_secrets_arm64 ]
143+ needs : [build_image_amd64, build_image_arm64 ]
126144 steps :
127145 - name : Set up Docker Buildx
128146 uses : docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
@@ -147,8 +165,8 @@ jobs:
147165
148166 - name : Create and push multi-architecture manifest for tag
149167 env :
150- ECR_REPOSITORY : ${{ inputs.git_secrets_container_ecr }}
151- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}
168+ ECR_REPOSITORY : ${{ inputs.container_ecr }}
169+ IMAGE_TAG : ${{ inputs.container_image_tag }}
152170 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
153171 run : |
154172 # Create manifest list combining both architectures
@@ -158,8 +176,8 @@ jobs:
158176
159177 - name : Verify multi-architecture manifest
160178 env :
161- ECR_REPOSITORY : ${{ inputs.git_secrets_container_ecr }}
162- IMAGE_TAG : ${{ inputs.git_secrets_container_image_tag }}
179+ ECR_REPOSITORY : ${{ inputs.container_ecr }}
180+ IMAGE_TAG : ${{ inputs.container_image_tag }}
163181 ACCOUNT_ID : ${{ steps.retrieve-deploy-account-id.outputs.account_id }}
164182 run : |
165183 echo "=== Verifying multi-architecture manifest ==="
0 commit comments