Skip to content

Commit a368b68

Browse files
Bot Updating Templated Files
1 parent c1deb5c commit a368b68

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

.github/workflows/external_trigger.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,30 @@ jobs:
4949
--header "Accept: application/vnd.oci.image.index.v1+json" \
5050
--header "Authorization: Bearer ${token}" \
5151
"https://ghcr.io/v2/${image}/manifests/${tag}")
52-
multidigest=$(jq -r ".manifests[] | select(.platform.architecture == \"amd64\").digest?" <<< "${multidigest}")
53-
digest=$(curl -s \
54-
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
55-
--header "Accept: application/vnd.oci.image.manifest.v1+json" \
56-
--header "Authorization: Bearer ${token}" \
57-
"https://ghcr.io/v2/${image}/manifests/${multidigest}" \
58-
| jq -r '.config.digest')
52+
if jq -e '.layers // empty' <<< "${multidigest}" >/dev/null 2>&1; then
53+
# If there's a layer element it's a single-arch manifest so just get that digest
54+
digest=$(jq -r '.config.digest' <<< "${multidigest}")
55+
else
56+
# Otherwise it's multi-arch or has manifest annotations
57+
if jq -e '.manifests[]?.annotations // empty' <<< "${multidigest}" >/dev/null 2>&1; then
58+
# Check for manifest annotations and delete if found
59+
multidigest=$(jq 'del(.manifests[] | select(.annotations))' <<< "${multidigest}")
60+
fi
61+
if [[ $(jq '.manifests | length' <<< "${multidigest}") -gt 1 ]]; then
62+
# If there's still more than one digest, it's multi-arch
63+
multidigest=$(jq -r ".manifests[] | select(.platform.architecture == \"amd64\").digest?" <<< "${multidigest}")
64+
else
65+
# Otherwise it's single arch
66+
multidigest=$(jq -r ".manifests[].digest?" <<< "${multidigest}")
67+
fi
68+
if digest=$(curl -s \
69+
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
70+
--header "Accept: application/vnd.oci.image.manifest.v1+json" \
71+
--header "Authorization: Bearer ${token}" \
72+
"https://ghcr.io/v2/${image}/manifests/${multidigest}"); then
73+
digest=$(jq -r '.config.digest' <<< "${digest}");
74+
fi
75+
fi
5976
image_info=$(curl -sL \
6077
--header "Authorization: Bearer ${token}" \
6178
"https://ghcr.io/v2/${image}/blobs/${digest}")

0 commit comments

Comments
 (0)