Skip to content

Commit 5ff1faf

Browse files
committed
feat: add image_tag_suffix support
1 parent 5a27f0f commit 5ff1faf

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

.github/workflows/build-docker-artifacts-config.schema.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
"type": "string",
4141
"description": "ECR repository to push the image to"
4242
},
43+
"image_tag_suffix": {
44+
"type": "string",
45+
"description": "Suffix to append to the image tag"
46+
},
47+
"image_tag_prefix": {
48+
"type": "string",
49+
"description": "Prefix to prepend to the image tag"
50+
},
4351
"scan_high_severity": {
4452
"type": "boolean",
4553
"default": true,
@@ -95,6 +103,14 @@
95103
"type": "object",
96104
"additionalProperties": false,
97105
"properties": {
106+
"image_tag_suffix": {
107+
"type": "string",
108+
"description": "Suffix to append to the image tag"
109+
},
110+
"image_tag_prefix": {
111+
"type": "string",
112+
"description": "Prefix to prepend to the image tag"
113+
},
98114
"source_repository": {
99115
"type": "string",
100116
"description": "Internal ECR repository name"

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ jobs:
118118
build_time: buildTime,
119119
image_tag: imageTag,
120120
image_tag_branch_name: imageTagBranchName,
121-
ecr_repositories: flavor.components.map(component => component.ecr_repository),
122121
test_images: {
123122
enabled: testImageEnabled,
124123
script_path: testImagesHookScript,
@@ -247,6 +246,8 @@ jobs:
247246
# Disable provenance as it creates weird multi-arch images: https://github.com/docker/build-push-action/issues/755
248247
provenance: false
249248
# Disable the cache to avoid outdated (base) images
249+
# TODO: are we sure we want this? We might benefit a lot from caching! But also, our base images like datavisyn/base/python:main are updated frequently and have no version tag...
250+
# maybe no-cache-filters works? Or we do this on our self-hosted runners: https://docs.docker.com/build/ci/github-actions/cache/#local-cache
250251
no-cache: true
251252
build-args: |
252253
GIT_BRANCH=${{ steps.get-branch.outputs.branch }}
@@ -432,13 +433,19 @@ jobs:
432433
echo "image_tag=$image_tag"
433434
echo "image_tag_branch_name=$image_tag_branch_name"
434435
435-
for repository_name in $(jq -r '.ecr_repositories[]' <<< "$FLAVOR"); do
436-
IMAGE_META=$(aws ecr describe-images --repository-name "$repository_name" --image-ids imageTag="$image_tag" --output json | jq --arg var "${image_tag_branch_name}" '.imageDetails[0].imageTags | index( $var )')
437-
if [[ -z "${IMAGE_META}" || ${IMAGE_META} == "null" ]]; then
436+
for component in $(jq -c '.components[]' <<< "$FLAVOR"); do
437+
repository_name=$(jq -r '.ecr_repository' <<< "$component")
438+
image_tag=$(jq -r '.image_tag' <<< "$component")
439+
image_tag_branch_name=$(jq -r '.image_tag_branch_name' <<< "$component")
440+
441+
echo "Processing repository: $repository_name, image_tag: $image_tag, image_tag_branch_name: $image_tag_branch_name"
442+
443+
IMAGE_META=$(aws ecr describe-images --repository-name "$repository_name" --image-ids imageTag="$image_tag" --output json | jq --arg var "${image_tag_branch_name}" '.imageDetails[0].imageTags | index($var)')
444+
if [[ -z "${IMAGE_META}" || "${IMAGE_META}" == "null" ]]; then
438445
MANIFEST=$(aws ecr batch-get-image --repository-name "$repository_name" --image-ids imageTag="$image_tag" --output json | jq --raw-output --join-output '.images[0].imageManifest')
439446
aws ecr put-image --repository-name "$repository_name" --image-tag "$image_tag_branch_name" --image-manifest "$MANIFEST"
440447
else
441-
echo "image already tagged!"
448+
echo "Image already tagged for repository: $repository_name!"
442449
fi
443450
done;
444451
env:

0 commit comments

Comments
 (0)