1616 branch :
1717 type : string
1818 required : false
19- # When using github.ref || github.head_ref, it would contain the full path, including /, which breaks the postgres hostname
20- default : ${{ github.sha }}
21- fail_fast :
19+ skip_push :
2220 type : boolean
2321 required : false
24- default : true
25- skip_image_scan :
22+ default : false
23+ fail_fast :
2624 type : boolean
2725 required : false
28- default : false
26+ default : true
2927 scan_high_severity :
3028 description : ' Include high severity'
3129 type : boolean
@@ -48,7 +46,7 @@ concurrency:
4846
4947env :
5048 WORKFLOW_BRANCH : " main"
51- PYTHON_BASE_IMAGE : " python:3.10.8 -slim-bullseye"
49+ PYTHON_BASE_IMAGE : " python:3.10.18 -slim-bullseye"
5250 DATAVISYN_PYTHON_BASE_IMAGE : " 188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/python:main"
5351 NODE_BASE_IMAGE : " node:20.9-bullseye"
5452 DATAVISYN_NGINX_BASE_IMAGE : " 188237246440.dkr.ecr.eu-central-1.amazonaws.com/datavisyn/base/nginx:main"
@@ -67,13 +65,13 @@ jobs:
6765 runs-on : ' ubuntu-22.04'
6866 steps :
6967 - name : Checkout repository
70- uses : actions/checkout@v4
68+ uses : actions/checkout@v5
7169 with :
72- ref : ${{ inputs.branch }}
70+ ref : ${{ inputs.branch || github.sha }}
7371 token : ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
7472
7573 - name : Checkout github-workflows repository
76- uses : actions/checkout@v4
74+ uses : actions/checkout@v5
7775 with :
7876 repository : datavisyn/github-workflows
7977 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -116,6 +114,10 @@ jobs:
116114 image_tag_branch_name: imageTagBranchName,
117115 ecr_respositories: flavor.components.map(component => component.ecr_repository),
118116 components: flavor.components.map(component => {
117+ // Format build arguments as build-args string
118+ const formattedBuildArgs = component.build_args ?
119+ Object.entries(component.build_args).map(([key, value]) => `${key}=${value}`).join('\n') : '';
120+
119121 return {
120122 ...component,
121123 // Add metadata to the component object (will be used as matrix input),
@@ -125,6 +127,7 @@ jobs:
125127 build_time: buildTime,
126128 image_tag: imageTag,
127129 image_tag_branch_name: imageTagBranchName,
130+ formatted_build_args: formattedBuildArgs,
128131 };
129132 }),
130133 };
@@ -163,15 +166,15 @@ jobs:
163166 sudo rm -rf /opt/ghc
164167 # TODO: Support arbitrary repositories, not just the current one?
165168 - name : Checkout repository
166- uses : actions/checkout@v4
169+ uses : actions/checkout@v5
167170 with :
168- ref : ${{ inputs.branch }}
171+ ref : ${{ inputs.branch || github.sha }}
169172 token : ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
170173 # This is required such that yarn install can access private repositories, i.e. visyn_pro
171174 # https://github.com/yarnpkg/yarn/issues/2614#issuecomment-2148174789
172175 persist-credentials : false
173176 - name : Checkout github-workflows repository
174- uses : actions/checkout@v4
177+ uses : actions/checkout@v5
175178 with :
176179 repository : datavisyn/github-workflows
177180 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -217,12 +220,15 @@ jobs:
217220 load : true
218221 # Disable provenance as it creates weird multi-arch images: https://github.com/docker/build-push-action/issues/755
219222 provenance : false
223+ # Disable the cache to avoid outdated (base) images
224+ no-cache : true
220225 build-args : |
221226 DOCKERFILE_DIRECTORY=${{ matrix.component.flavor_directory }}/${{ matrix.component.directory }}
222227 PYTHON_BASE_IMAGE=${{ env.PYTHON_BASE_IMAGE }}
223228 DATAVISYN_PYTHON_BASE_IMAGE=${{ env.DATAVISYN_PYTHON_BASE_IMAGE }}
224229 NODE_BASE_IMAGE=${{ env.NODE_BASE_IMAGE }}
225230 DATAVISYN_NGINX_BASE_IMAGE=${{ env.DATAVISYN_NGINX_BASE_IMAGE }}
231+ ${{ matrix.component.formatted_build_args }}
226232 secrets :
227233 # Mount the token as secret mount: https://docs.docker.com/build/ci/github-actions/secrets/#secret-mounts
228234 " github_token=${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}"
@@ -256,10 +262,11 @@ jobs:
256262 echo "severity=HIGH,CRITICAL" >> "$GITHUB_OUTPUT"
257263 fi
258264 - name : Run Trivy vulnerability scanner
259- if : ${{ inputs.skip_image_scan != true && fromJson(vars.SKIP_IMAGE_SCAN || 'false') != true && matrix.component.skip_image_scan != true }}
260- uses :
aquasecurity/[email protected] 265+ uses :
aquasecurity/[email protected] 261266 with :
262267 image-ref : ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
268+ # Disable scanning the current directory (defaults to .)
269+ scan-ref : ' /dev/null'
263270 format : ' table'
264271 exit-code : ' 1'
265272 ignore-unfixed : false
@@ -268,38 +275,9 @@ jobs:
268275 continue-on-error : false
269276
270277 - name : Push image
271- uses : docker/build-push-action@v6
272- with :
273- context : .
274- file : ${{ matrix.component.flavor_directory }}/${{ matrix.component.directory }}/Dockerfile
275- push : true
276- # Disable provenance as it creates weird multi-arch images: https://github.com/docker/build-push-action/issues/755
277- provenance : false
278- # Duplicated the build-args, secrets, tags and labels from the actual build above
279- # TODO: How can we avoid the build here and just push with this action?
280- build-args : |
281- DOCKERFILE_DIRECTORY=${{ matrix.component.flavor_directory }}/${{ matrix.component.directory }}
282- PYTHON_BASE_IMAGE=${{ env.PYTHON_BASE_IMAGE }}
283- DATAVISYN_PYTHON_BASE_IMAGE=${{ env.DATAVISYN_PYTHON_BASE_IMAGE }}
284- NODE_BASE_IMAGE=${{ env.NODE_BASE_IMAGE }}
285- DATAVISYN_NGINX_BASE_IMAGE=${{ env.DATAVISYN_NGINX_BASE_IMAGE }}
286- secrets :
287- # Mount the token as secret mount: https://docs.docker.com/build/ci/github-actions/secrets/#secret-mounts
288- " github_token=${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}"
289- # TODO: As soon as we only have a single tag, we can push the same image to multiple repositories: https://docs.docker.com/build/ci/github-actions/push-multi-registries/
290- # This will be useful for the images which don't change between flavors, e.g. the backend images
291- tags : |
292- ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
293- labels : |
294- name=${{ matrix.component.ecr_repository }}
295- version=${{ matrix.component.image_tag_branch_name }}
296- org.opencontainers.image.description=Image for ${{ matrix.component.ecr_repository }}
297- org.opencontainers.image.source=${{ github.event.repository.html_url }}
298- org.opencontainers.image.url=${{ github.event.repository.html_url }}
299- org.opencontainers.image.title=${{ matrix.component.ecr_repository }}
300- org.opencontainers.image.version=${{ matrix.component.image_tag_branch_name }}
301- org.opencontainers.image.created=${{ matrix.component.build_time }}
302- org.opencontainers.image.revision=${{ github.sha }}
278+ if : ${{ inputs.skip_push != true }}
279+ # Instead of the docker/build-push-action@v6 which will rebuild the image, just push it directly
280+ run : docker push ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
303281
304282 - name : Log out from Amazon ECR
305283 shell : bash
@@ -308,6 +286,7 @@ jobs:
308286 retag-images :
309287 name : Retag images of flavor ${{ matrix.flavor || 'default' }}
310288 needs : [get-flavors, build-flavors]
289+ if : ${{ inputs.skip_push != true }}
311290 strategy :
312291 fail-fast : false
313292 matrix :
@@ -317,13 +296,13 @@ jobs:
317296 runs-on : ' ubuntu-22.04'
318297 steps :
319298 - name : Checkout repository
320- uses : actions/checkout@v4
299+ uses : actions/checkout@v5
321300 with :
322- ref : ${{ inputs.branch }}
301+ ref : ${{ inputs.branch || github.sha }}
323302 token : ${{ secrets.CHECKOUT_TOKEN || github.event.repository.private == true && secrets.DATAVISYN_BOT_REPO_TOKEN || github.token }}
324303
325304 - name : Checkout github-workflows repository
326- uses : actions/checkout@v4
305+ uses : actions/checkout@v5
327306 with :
328307 repository : datavisyn/github-workflows
329308 ref : ${{ env.WORKFLOW_BRANCH }}
@@ -367,12 +346,12 @@ jobs:
367346 push-to-repositories :
368347 name : Push images to push targets
369348 # if? When should we do this? Always? Only for certain branches? If so, how should we define that, in the config.json?
370- if : ${{ fromJson(needs.get-flavors.outputs.result).push_to != '' }}
349+ if : ${{ inputs.skip_push != true && fromJson(needs.get-flavors.outputs.result).push_to != '' }}
371350 needs : [retag-images, get-flavors]
372351 uses : datavisyn/github-workflows/.github/workflows/build-docker-artifacts-trigger-push.yml@main
373352 secrets : inherit
374353 with :
375354 push_to : ${{ fromJson(needs.get-flavors.outputs.result).push_to }}
376- branch : ${{ inputs.branch }}
355+ branch : ${{ inputs.branch || github.sha }}
377356 # Do not run this on self-hosted, as it is faster and shouldn't be blocking anything
378357 # runs_on: ${{ inputs.runs_on || 'ubuntu-22.04' }}
0 commit comments