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.
This commit is contained in:
parent
42b985e07b
commit
d44ca50dd1
1 changed files with 8 additions and 14 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue