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"