@@ -124,6 +124,7 @@ jobs:
124124 flavor_directory: `./deploy/build/${flavor.directory}`,
125125 build_time: buildTime,
126126 image_tag: imageTag,
127+ image_ref: `${{ vars.DV_AWS_ECR_REGISTRY }}/${component.ecr_repository}:${imageTag}`,
127128 image_tag_branch_name: imageTagBranchName,
128129 formatted_build_args: formattedBuildArgs,
129130 };
@@ -240,7 +241,7 @@ jobs:
240241 # # 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/
241242 # # This will be useful for the images which don't change between flavors, e.g. the backend images
242243 # tags: |
243- # ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
244+ # ${{ matrix.component.image_ref }}
244245 # labels: |
245246 # name=${{ matrix.component.ecr_repository }}
246247 # version=${{ matrix.component.image_tag_branch_name }}
@@ -269,7 +270,7 @@ jobs:
269270 # - name: Run Trivy vulnerability scanner
270271 # uses: aquasecurity/[email protected] 271272 # with:
272- # image-ref: ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
273+ # image-ref: ${{ matrix.component.image_ref }}
273274 # # Disable scanning the current directory (defaults to .)
274275 # scan-ref: '/dev/null'
275276 # format: 'table'
@@ -282,7 +283,7 @@ jobs:
282283 # - name: Push image
283284 # if: ${{ inputs.skip_push != true }}
284285 # # Instead of the docker/build-push-action@v6 which will rebuild the image, just push it directly
285- # run: docker push ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
286+ # run: docker push ${{ matrix.component.image_ref }}
286287
287288 # - name: Log out from Amazon ECR
288289 # shell: bash
@@ -326,6 +327,16 @@ jobs:
326327 directory="./deploy/build/"${{ matrix.flavor.directory }}""
327328 cd "$directory"
328329
330+ # Iterate through all components and store their image ref in an environment variable
331+ for component in $(jq -c '.components[]' <<< "$FLAVOR"); do
332+ name=$(jq -r '.ecr_repository' <<< "$component")
333+ image_ref=$(jq -r '.image_ref' <<< "$component")
334+ # Replace all non-alphanumeric characters with underscores and convert to uppercase
335+ name_upper=$(echo "${name//[^[:alnum:]]/_}" | tr '[:lower:]' '[:upper:]')
336+ echo "Setting environment variable IMAGE_$name_upper=$image_ref"
337+ export "IMAGE_$name_upper=$image_ref"
338+ done;
339+
329340 if [[ -f "./hooks/test_images.sh" ]]; then
330341 echo "Run test_images.sh in $directory"
331342 chmod +x ./hooks/test_images.sh
0 commit comments