ci: harden assemble step (pinned buildx, plain progress, timeout) and verify every tag in every registry
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
99279d5347
commit
68976142f5
1 file changed
+72
-2
@@ -133,22 +133,92 @@ jobs:
|
|||||||
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
|
PKG_CACHE=${{ steps.pkgcache.outputs.url }}
|
||||||
outputs: type=image,"name=repo.anhonesthost.net/cloud-hosting-platform/haproxy-manager-base,ghcr.io/shadowdao/haproxy-manager-base",push-by-digest=true,name-canonical=true,push=true
|
outputs: type=image,"name=repo.anhonesthost.net/cloud-hosting-platform/haproxy-manager-base,ghcr.io/shadowdao/haproxy-manager-base",push-by-digest=true,name-canonical=true,push=true
|
||||||
|
|
||||||
|
# imagetools needs a NEW buildx. Same pinned, sha256-verified binary as
|
||||||
|
# mirror-base-image.yaml (kept identical on purpose). The assemble step
|
||||||
|
# previously ran on whatever buildx the (possibly ephemeral) runner had
|
||||||
|
# (0.13.1 on the runner that hung in run 5375, 0.15.1 on the trusted one).
|
||||||
|
- name: Install pinned buildx
|
||||||
|
env:
|
||||||
|
BUILDX_VERSION: v0.28.0
|
||||||
|
BUILDX_SHA256: 696bc104bac3bb708eff1af3f8bbc09fda0fd88f5757c1f9b404a35117889224
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
dir="${RUNNER_TEMP:-/tmp}/pinned-buildx"; mkdir -p "$dir"
|
||||||
|
curl -fsSL --retry 3 --max-time 120 -o "$dir/docker-buildx" \
|
||||||
|
"https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64"
|
||||||
|
echo "${BUILDX_SHA256} $dir/docker-buildx" | sha256sum -c -
|
||||||
|
chmod +x "$dir/docker-buildx"
|
||||||
|
"$dir/docker-buildx" version
|
||||||
|
echo "BUILDX=$dir/docker-buildx" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
# main: three tags per registry: :latest (moving), :<version> (human-readable
|
# main: three tags per registry: :latest (moving), :<version> (human-readable
|
||||||
# release), :<sha> (immutable, guaranteed-unique rollback target).
|
# release), :<sha> (immutable, guaranteed-unique rollback target).
|
||||||
# release/* or rc-*: :<version>-rc and :<sha> only (see "Resolve tags").
|
# release/* or rc-*: :<version>-rc and :<sha> only (see "Resolve tags").
|
||||||
|
# Hardened after run 5375 (assemble hung after pushing, TTY progress, old
|
||||||
|
# buildx): plain progress, pinned buildx, hard 10 minute step timeout.
|
||||||
- name: Assemble tag indexes
|
- name: Assemble tag indexes
|
||||||
|
id: assemble
|
||||||
|
timeout-minutes: 10
|
||||||
env:
|
env:
|
||||||
|
BUILDKIT_PROGRESS: plain
|
||||||
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
|
AMD64_DIGEST: ${{ steps.amd64.outputs.digest }}
|
||||||
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
|
ARM64_DIGEST: ${{ steps.arm64.outputs.digest }}
|
||||||
ARM64_OUTCOME: ${{ steps.arm64.outcome }}
|
ARM64_OUTCOME: ${{ steps.arm64.outcome }}
|
||||||
VERSION: ${{ steps.ver.outputs.version }}
|
VERSION: ${{ steps.ver.outputs.version }}
|
||||||
TAGS: ${{ steps.tags.outputs.tags }}
|
TAGS: ${{ steps.tags.outputs.tags }}
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
tag_args=()
|
tag_args=()
|
||||||
for t in $TAGS; do tag_args+=(--tag "$t"); done
|
for t in $TAGS; do tag_args+=(--tag "$t"); done
|
||||||
scripts/assemble-multiarch-index.sh \
|
# Use the pinned buildx for create AND the script's platform inspects.
|
||||||
|
export IMAGETOOLS="${BUILDX} imagetools"
|
||||||
|
out=$(scripts/assemble-multiarch-index.sh \
|
||||||
--amd64 "$AMD64_DIGEST" \
|
--amd64 "$AMD64_DIGEST" \
|
||||||
--arm64 "$ARM64_DIGEST" --arm64-outcome "$ARM64_OUTCOME" \
|
--arm64 "$ARM64_DIGEST" --arm64-outcome "$ARM64_OUTCOME" \
|
||||||
--repo repo.anhonesthost.net/cloud-hosting-platform/haproxy-manager-base \
|
--repo repo.anhonesthost.net/cloud-hosting-platform/haproxy-manager-base \
|
||||||
--repo ghcr.io/shadowdao/haproxy-manager-base \
|
--repo ghcr.io/shadowdao/haproxy-manager-base \
|
||||||
"${tag_args[@]}"
|
"${tag_args[@]}" | tee /dev/stderr)
|
||||||
|
platforms=$(printf '%s\n' "$out" | sed -n 's/^platforms=//p' | tail -n1)
|
||||||
|
[ -n "$platforms" ] || { echo "::error::assemble script reported no platforms line"; exit 1; }
|
||||||
|
if [ "$platforms" = "linux/amd64" ]; then
|
||||||
|
echo "::warning::SINGLE-ARCH publish (amd64 only) on purpose: arm64 outcome was '${ARM64_OUTCOME}'. Tags carry no arm64 manifest."
|
||||||
|
else
|
||||||
|
echo "multi-arch publish: ${platforms}"
|
||||||
|
fi
|
||||||
|
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# Final gate: every tag in every registry must resolve, carry the platforms
|
||||||
|
# the assemble step reported, and have ONE digest across all tags and both
|
||||||
|
# registries (they are built from the same sources). Any miss fails the job
|
||||||
|
# instead of trusting that the create calls "looked" fine.
|
||||||
|
- name: Verify published tags in every registry
|
||||||
|
timeout-minutes: 10
|
||||||
|
env:
|
||||||
|
BUILDKIT_PROGRESS: plain
|
||||||
|
TAGS: ${{ steps.tags.outputs.tags }}
|
||||||
|
PLATFORMS: ${{ steps.assemble.outputs.platforms }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
repos="repo.anhonesthost.net/cloud-hosting-platform/haproxy-manager-base ghcr.io/shadowdao/haproxy-manager-base"
|
||||||
|
want=$(printf '%s' "$PLATFORMS" | tr ',' '\n' | sort | tr '\n' ' ')
|
||||||
|
ref_digest=""; ref_name=""; fail=0
|
||||||
|
for r in $repos; do
|
||||||
|
for t in $TAGS; do
|
||||||
|
ref="${r}:${t}"
|
||||||
|
if ! d=$(timeout 90 $BUILDX imagetools inspect "$ref" --format '{{.Manifest.Digest}}' 2>&1); then
|
||||||
|
echo "::error::MISSING or unreadable: ${ref}: ${d}"; fail=1; continue
|
||||||
|
fi
|
||||||
|
[[ "$d" =~ ^sha256:[0-9a-f]{64}$ ]] || { echo "::error::bad digest for ${ref}: ${d}"; fail=1; continue; }
|
||||||
|
got=$(timeout 90 $BUILDX imagetools inspect "$ref" --format '{{range .Manifest.Manifests}}{{if ne .Platform.OS "unknown"}}{{.Platform.OS}}/{{.Platform.Architecture}}{{"\n"}}{{end}}{{end}}' | sort | tr '\n' ' ')
|
||||||
|
if [ "$got" != "$want" ]; then
|
||||||
|
echo "::error::platform mismatch for ${ref}: have [${got}] want [${want}]"; fail=1
|
||||||
|
fi
|
||||||
|
echo "ok ${ref} ${d} [${got}]"
|
||||||
|
if [ -z "$ref_digest" ]; then ref_digest="$d"; ref_name="$ref"
|
||||||
|
elif [ "$d" != "$ref_digest" ]; then
|
||||||
|
echo "::error::digest mismatch: ${ref}=${d} vs ${ref_name}=${ref_digest}"; fail=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
[ "$fail" = 0 ] || { echo "::error::tag verification FAILED"; exit 1; }
|
||||||
|
echo "verified: ${TAGS} in both registries, digest ${ref_digest}, platforms ${PLATFORMS}"
|
||||||
Reference in new issue
Block a user