Track the CI image hash with a label instead of a tag
CI / build-image (arm64, ubuntu-latest-arm64) (push) Failing after 3m47s
CI / build-image (amd64, ubuntu-latest-amd64) (push) Failing after 3m47s
CI / pre-commit (push) Has been skipped
CI / test (-DCMAKE_BUILD_TYPE=Debug, debug) (push) Has been skipped
CI / test (-DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 64-bit-versions) (push) Has been skipped
CI / test (-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, gcc) (push) Has been skipped
CI / test (-DUSE_SIMD_FALLBACK=ON, simd-fallback) (push) Has been skipped
CI / release (amd64, ubuntu-latest-amd64) (push) Has been skipped
CI / release (arm64, ubuntu-latest-arm64) (push) Has been skipped
CI / coverage (push) Has been skipped

Pushing per-hash tags accumulates multi-GB versions in the registry,
and package cleanup rules can't distinguish the hash tags that the
latest-{arch} tags currently point to from stale ones. Push only
latest-{arch} and record the Dockerfile hash as an image label; the
skip-rebuild check reads the label back via buildx imagetools.
This commit is contained in:
2026-06-12 12:16:34 -04:00
parent cbbb23bf9d
commit 12a62a91cf
+7 -11
View File
@@ -24,18 +24,14 @@ jobs:
- name: Build and push image if changed - name: Build and push image if changed
run: | run: |
image=git.weaselab.dev/weaselab/conflict-set-ci image=git.weaselab.dev/weaselab/conflict-set-ci
tag="$(sha256sum Dockerfile .pre-commit-config.yaml | sha256sum | cut -c 1-16)-${{ matrix.arch }}" hash="$(sha256sum Dockerfile .pre-commit-config.yaml | sha256sum | cut -c 1-16)"
latest=latest-${{ matrix.arch }} latest="$image:latest-${{ matrix.arch }}"
if docker manifest inspect "$image:$tag" > /dev/null 2>&1; then current="$(docker buildx imagetools inspect "$latest" \
if [ "$(docker manifest inspect "$image:$tag")" = "$(docker manifest inspect "$image:$latest" 2> /dev/null)" ]; then --format '{{index .Image.Config.Labels "dev.weaselab.ci-hash"}}' 2> /dev/null || true)"
echo "$image:$latest is up to date" if [ "$current" = "$hash" ]; then
else echo "$latest is up to date"
docker pull "$image:$tag"
docker tag "$image:$tag" "$image:$latest"
docker push "$image:$latest"
fi
else else
docker build --push -t "$image:$tag" -t "$image:$latest" . docker build --push --label "dev.weaselab.ci-hash=$hash" -t "$latest" .
fi fi
pre-commit: pre-commit: