From d44ca50dd1722200e6bef745ca08a6e17484848d Mon Sep 17 00:00:00 2001 From: devops Date: Fri, 4 Dec 2026 00:19:06 -0500 Subject: [PATCH] ci(backup): take the pushed digest from buildx metadata, not imagetools Forgejo's /v2/token answers 403 to the scope set buildx imagetools uses (measured on this registry), while push and kubelet pull work. The metadata file is the authoritative digest of the manifest the registry just accepted. --- .forgejo/workflows/backup-image.yml | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/backup-image.yml b/.forgejo/workflows/backup-image.yml index c55aadd..6be2909 100644 --- a/.forgejo/workflows/backup-image.yml +++ b/.forgejo/workflows/backup-image.yml @@ -52,24 +52,18 @@ jobs: # --provenance=false --sbom=false: the tag must resolve to the single # amd64 image manifest, so the digest a CronJob pins is exactly the # image the pod runs (an index digest would resolve per-arch). + # --metadata-file carries the pushed manifest digest. Do NOT read it + # back with `buildx imagetools inspect`: Forgejo's /v2/token answers + # 403 to that scope set (measured), while push and kubelet pull are + # fine. docker buildx build --platform linux/amd64 \ --provenance=false --sbom=false \ -t "$image:$sha" \ - --push images/backup + --push --metadata-file /tmp/build-meta.json images/backup echo "pushed $image:$sha" - - - name: Print the digest to pin - env: - REG_USER: ${{ secrets.REGISTRY_USER }} - REG_PASS: ${{ secrets.REGISTRY_TOKEN }} - run: | - set -euo pipefail - sha=$(git rev-parse HEAD) - image=forgejo.siriusdevops.com/sirius/backup-tools - user="${REG_USER:-sirius}" - pass="${REG_PASS:-${{ github.token }}}" - echo "$pass" | docker login forgejo.siriusdevops.com -u "$user" --password-stdin - digest=$(docker buildx imagetools inspect "$image:$sha" --format '{{.Manifest.Digest}}') + digest=$(tr -d '\n' < /tmp/build-meta.json \ + | sed -n 's/.*"containerimage\.digest": *"\(sha256:[a-f0-9]*\)".*/\1/p') + [ -n "$digest" ] || { echo "::error::no containerimage.digest in build metadata"; cat /tmp/build-meta.json; exit 1; } echo "BACKUP_TOOLS_DIGEST=$digest" { echo "### Pin this in the three backup CronJob manifests"