File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,11 +5,12 @@ REGISTRY="${1:?registry required}"
55REPOSITORY=" ${2:? repository required} "
66SOURCE_TAG=" ${3:? source tag required} "
77DEPLOY_TAG=" ${4:? deploy tag required} "
8+ RELEASE_TAG=" ${5:- } "
89: " ${GITHUB_OUTPUT:? GitHub output file required} "
910SCRIPT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd)
1011PREVIOUS=$( bash " $SCRIPT_DIR /get-ecr-image-digest.sh" " $REPOSITORY " " $DEPLOY_TAG " --allow-missing)
1112EPOCH=$( date +%s)
12- docker buildx imagetools create -t " $REGISTRY / $REPOSITORY : $ DEPLOY_TAG" " $REGISTRY / $REPOSITORY : $SOURCE_TAG "
13+ bash " $SCRIPT_DIR /promote-image.sh " " $REGISTRY " " $REPOSITORY " " $SOURCE_TAG " " $ DEPLOY_TAG" " $RELEASE_TAG "
1314DIGEST=$( bash " $SCRIPT_DIR /get-ecr-image-digest.sh" " $REPOSITORY " " $DEPLOY_TAG " )
1415CHANGED=true
1516if [ " $DIGEST " = " $PREVIOUS " ]; then CHANGED=false; fi
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # Point a deploy tag (and, for production, its release-<sha> alias) at a built image.
3+ # One imagetools call writes both tags, so they always share one list digest.
4+ set -euo pipefail
5+ REGISTRY=" ${1:? registry required} "
6+ REPOSITORY=" ${2:? repository required} "
7+ SOURCE_TAG=" ${3:? source tag required} "
8+ DEPLOY_TAG=" ${4:? deploy tag required} "
9+ RELEASE_TAG=" ${5:- } "
10+ TAG_ARGS=(-t " $REGISTRY /$REPOSITORY :$DEPLOY_TAG " )
11+ if [ -n " $RELEASE_TAG " ]; then TAG_ARGS+=(-t " $REGISTRY /$REPOSITORY :$RELEASE_TAG " ); fi
12+ docker buildx imagetools create " ${TAG_ARGS[@]} " " $REGISTRY /$REPOSITORY :$SOURCE_TAG "
Original file line number Diff line number Diff line change @@ -520,8 +520,11 @@ jobs:
520520 run : |
521521 REGISTRY="${{ steps.login-ecr.outputs.registry }}"
522522
523+ RELEASE_TAG=""
523524 if [ "${{ github.ref }}" = "refs/heads/main" ]; then
524525 ECR_TAG="latest"
526+ # ECR lifecycle retains release- aliases as prod rollback targets.
527+ RELEASE_TAG="release-${SOURCE_TAG}"
525528 elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then
526529 ECR_TAG="dev"
527530 else
@@ -540,13 +543,11 @@ jobs:
540543 # Move the app last so a preceding tag failure cannot start app rollout
541544 # and then skip the downstream Trigger promotion job.
542545 for repo in $ECR_REPOS; do
543- echo "🚀 Promoting ${repo}:${SOURCE_TAG} to ${ECR_TAG}"
546+ echo "🚀 Promoting ${repo}:${SOURCE_TAG} to ${ECR_TAG}${RELEASE_TAG:+ and ${RELEASE_TAG}} "
544547 if [ "$repo" = "$APP_REPO" ]; then
545- bash .github/scripts/promote-app-image.sh "$REGISTRY" "$APP_REPO" "$SOURCE_TAG" "$ECR_TAG"
548+ bash .github/scripts/promote-app-image.sh "$REGISTRY" "$APP_REPO" "$SOURCE_TAG" "$ECR_TAG" "$RELEASE_TAG"
546549 else
547- docker buildx imagetools create \
548- -t "${REGISTRY}/${repo}:${ECR_TAG}" \
549- "${REGISTRY}/${repo}:${SOURCE_TAG}"
550+ bash .github/scripts/promote-image.sh "$REGISTRY" "$repo" "$SOURCE_TAG" "$ECR_TAG" "$RELEASE_TAG"
550551 fi
551552 done
552553
You can’t perform that action at this time.
0 commit comments