Skip to content

Commit 0da8b1b

Browse files
authored
fix(ci): fix workflow build-push-images.yaml to get the digest for single-platform images (#1546) (#1605)
Signed-off-by: Cheng Fang <cfang@redhat.com>
1 parent b782db1 commit 0da8b1b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

.github/workflows/build-push-images.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ jobs:
103103
local inspect
104104
inspect=$(docker manifest inspect "${IMAGE_NAME}:${tag}" 2>/dev/null) || return 1
105105
if echo "${inspect}" | jq -e '.manifests' >/dev/null 2>&1; then
106+
# Manifest list: extract the digest for the requested platform
106107
local digest
107108
digest=$(echo "${inspect}" | jq -r --arg a "${arch}" '.manifests[] | select(.platform.architecture == $a) | .digest' | head -n1)
108109
[ -n "${digest}" ] && echo "${IMAGE_NAME}@${digest}" || return 1
109110
else
111+
# Single-platform image: get digest from verbose inspect descriptor
110112
local digest
111-
digest=$(docker buildx imagetools inspect "${IMAGE_NAME}:${tag}" --format '{{.Digest}}' 2>/dev/null) || return 1
112-
[ -n "${digest}" ] && echo "${IMAGE_NAME}@${digest}" || return 1
113+
digest=$(docker manifest inspect --verbose "${IMAGE_NAME}:${tag}" 2>/dev/null | jq -r '.Descriptor.digest')
114+
[ -n "${digest}" ] && [ "${digest}" != "null" ] && echo "${IMAGE_NAME}@${digest}" || return 1
113115
fi
114116
}
115117

0 commit comments

Comments
 (0)