fix(ci): tolerate buildx's pretty-printed metadata-file JSON when extracting digest
Some checks failed
build-and-release / build (push) Failing after 1h49m45s

docker buildx --metadata-file writes pretty-printed JSON (space after
the colon: "containerimage.digest": "sha256:..."), but the digest
grep required compact JSON with no space, so it always matched
nothing. That produced an empty $digest, which the script correctly
treated as fatal and exited on - right after the first service
(gateway) had already built and pushed successfully, silently
aborting the rest of the service loop. Verified the fix against a
real locally-generated metadata file from the same buildx command.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Ashwin Kumar Sivakumar 2026-07-08 00:03:32 +05:30
parent d422139e48
commit 968960fb3d

View file

@ -140,7 +140,10 @@ jobs:
-t "$image_ref" \ -t "$image_ref" \
. .
digest="$(grep -o '"containerimage.digest":"sha256:[^"]*"' "$metadata_file" | cut -d'"' -f4)" # buildx writes the metadata file pretty-printed (space after the
# colon), which the old compact-JSON-only pattern never matched -
# tolerate optional whitespace and extract the digest directly.
digest="$(grep -o '"containerimage\.digest"[[:space:]]*:[[:space:]]*"sha256:[^"]*"' "$metadata_file" | grep -o 'sha256:[^"]*')"
if [ -z "$digest" ]; then if [ -z "$digest" ]; then
echo "Failed to determine digest for $service" >&2 echo "Failed to determine digest for $service" >&2
exit 1 exit 1