Skip to content

Commit d038d9a

Browse files
committed
fix(ci): predict the promoted app digest instead of trusting a read right after the retag
1 parent d1b6519 commit d038d9a

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎.github/scripts/promote-app-image.sh‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,22 @@ RELEASE_TAG="${5:-}"
99
: "${GITHUB_OUTPUT:?GitHub output file required}"
1010
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
1111
PREVIOUS=$(bash "$SCRIPT_DIR/get-ecr-image-digest.sh" "$REPOSITORY" "$DEPLOY_TAG" --allow-missing)
12+
# A tag read straight after the move can still return the previous image, which
13+
# reports a moved tag as unchanged. The dry run prints the exact manifest the
14+
# move pushes (plus a trailing newline), so its hash is the digest the tag will
15+
# point at, known before the move.
16+
MANIFEST=$(docker buildx imagetools create --dry-run -t "$REGISTRY/$REPOSITORY:$DEPLOY_TAG" "$REGISTRY/$REPOSITORY:$SOURCE_TAG")
17+
DIGEST="sha256:$(printf '%s' "$MANIFEST" | sha256sum | cut -d' ' -f1)"
1218
EPOCH=$(date +%s)
1319
bash "$SCRIPT_DIR/promote-image.sh" "$REGISTRY" "$REPOSITORY" "$SOURCE_TAG" "$DEPLOY_TAG" "$RELEASE_TAG"
14-
DIGEST=$(bash "$SCRIPT_DIR/get-ecr-image-digest.sh" "$REPOSITORY" "$DEPLOY_TAG")
20+
for attempt in $(seq 1 20); do
21+
[ "$(bash "$SCRIPT_DIR/get-ecr-image-digest.sh" "$REPOSITORY" "$DEPLOY_TAG" --allow-missing)" = "$DIGEST" ] && break
22+
if [ "$attempt" -eq 20 ]; then
23+
echo "ERROR: $DEPLOY_TAG never resolved to the pushed $DIGEST; cutover cannot be correlated" >&2
24+
exit 1
25+
fi
26+
sleep 3
27+
done
1528
CHANGED=true
1629
if [ "$DIGEST" = "$PREVIOUS" ]; then CHANGED=false; fi
1730
{

0 commit comments

Comments
 (0)