Skip to content

Commit 40ee430

Browse files
committed
Add IMAGE_... env variables
1 parent 1e28dbe commit 40ee430

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

.github/workflows/build-docker-artifacts.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ jobs:
9797
9898
const buildTime = new Date().toISOString().replace(/:/g, '').replace(/\..+/, 'Z');
9999
const imageTagBranchName = "${{ github.ref }}".replace('refs/heads/', '').replace('refs/tags/', '').replace(/[^a-zA-Z0-9._-]/g, '-');
100-
const imageTag = `tagged-${imageTagBranchName}-${buildTime}`;
100+
// const imageTag = `tagged-${imageTagBranchName}-${buildTime}`;
101+
const imageTag = "v32.1.0"; // TODO: Revert to dynamic tag
101102
102103
const builds = process.env.BUILDS ? process.env.BUILDS.split(',') : Object.keys(config.build);
103104
const push_to = process.env.PUSH_TO ? process.env.PUSH_TO.split(',') : Object.keys(config.push || {});
@@ -124,6 +125,7 @@ jobs:
124125
flavor_directory: `./deploy/build/${flavor.directory}`,
125126
build_time: buildTime,
126127
image_tag: imageTag,
128+
image_ref: `${{ vars.DV_AWS_ECR_REGISTRY }}/${component.ecr_repository}:${imageTag}`,
127129
image_tag_branch_name: imageTagBranchName,
128130
formatted_build_args: formattedBuildArgs,
129131
};
@@ -240,7 +242,7 @@ jobs:
240242
# # 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/
241243
# # This will be useful for the images which don't change between flavors, e.g. the backend images
242244
# tags: |
243-
# ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
245+
# ${{ matrix.component.image_ref }}
244246
# labels: |
245247
# name=${{ matrix.component.ecr_repository }}
246248
# version=${{ matrix.component.image_tag_branch_name }}
@@ -269,7 +271,7 @@ jobs:
269271
# - name: Run Trivy vulnerability scanner
270272
# uses: aquasecurity/[email protected]
271273
# with:
272-
# image-ref: ${{ vars.DV_AWS_ECR_REGISTRY }}/${{ matrix.component.ecr_repository }}:${{ matrix.component.image_tag }}
274+
# image-ref: ${{ matrix.component.image_ref }}
273275
# # Disable scanning the current directory (defaults to .)
274276
# scan-ref: '/dev/null'
275277
# format: 'table'
@@ -282,7 +284,7 @@ jobs:
282284
# - name: Push image
283285
# if: ${{ inputs.skip_push != true }}
284286
# # 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 }}
287+
# run: docker push ${{ matrix.component.image_ref }}
286288

287289
# - name: Log out from Amazon ECR
288290
# shell: bash
@@ -326,6 +328,19 @@ jobs:
326328
directory="./deploy/build/"${{ matrix.flavor.directory }}""
327329
cd "$directory"
328330
331+
# Iterate through all components and store their image ref in an environment variable
332+
for component in $(jq -c '.components[]' <<< "$FLAVOR"); do
333+
name=$(jq -r '.ecr_repository' <<< "$component")
334+
image_ref=$(jq -r '.image_ref' <<< "$component")
335+
# Replace all non-alphanumeric characters with underscores and convert to uppercase
336+
name_upper=$(echo "${name//[^[:alnum:]]/_}" | tr '[:lower:]' '[:upper:]')
337+
echo "Setting environment variable IMAGE_$name_upper=$image_ref"
338+
export "IMAGE_$name_upper=$image_ref"
339+
340+
# Pull the image to ensure it is available locally
341+
docker pull "$image_ref"
342+
done;
343+
329344
if [[ -f "./hooks/test_images.sh" ]]; then
330345
echo "Run test_images.sh in $directory"
331346
chmod +x ./hooks/test_images.sh

0 commit comments

Comments
 (0)