Add GHCR pruning workflow that respects multi-arch manifests - #48
Merged
Conversation
Nothing in CI reclaimed package storage, so every release left its intermediate builds behind in GHCR. The obvious fix — actions/delete-package-versions with delete-only-untagged-versions — is unsafe here. release.yml publishes per-arch images and merges them with `docker buildx imagetools create`, so each release tag is an OCI index whose per-platform and attestation manifests appear in the packages API as untagged versions. Deleting all untagged versions would break `docker pull` for latest, 0.0.2 and 0.0.1, which reference those manifests directly. Instead, resolve the manifest graph from the registry and prune in two passes: drop disposable commit-SHA dev builds, then recompute reachability against the survivors and delete only what nothing points to. Releases and latest are protected by pattern, with a keep_days floor for recent builds. Runs manually with a dry_run toggle (default true) plus a weekly cron. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HvwxjJxDn9eq4HaMz5mrEw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nothing in CI reclaimed package storage, so every release left intermediate builds behind in GHCR — 34 container versions across 6 builds, of which only 2 are releases.
The obvious fix (
actions/delete-package-versionswithdelete-only-untagged-versions: true) is actively unsafe here:release.ymlmerges per-arch images withdocker buildx imagetools create, so each release tag is an OCI index whose per-platform and attestation manifests appear in the packages API as untagged versions — deleting all untagged versions would breakdocker pullforlatest,0.0.2and0.0.1, which reference them directly.This instead resolves the manifest graph from the registry and prunes in two passes: drop disposable commit-SHA dev builds, then recompute reachability against the survivors and delete only what nothing points to, with releases and
latestprotected by pattern and akeep_daysfloor for recent builds.Runs manually with a
dry_runtoggle (default true) plus a weekly cron; verified in dry-run against the live package — 22 of 34 versions pruned, both releases andlatestintact, all 8 of their referenced child manifests protected.Note: if a real run 403s,
GITHUB_TOKENlacks delete rights on packages — add a classic PAT withdelete:packagesas aPACKAGES_TOKENsecret and the workflow will prefer it. That path is untested since testing it requires a live deletion.🤖 Generated with Claude Code
https://claude.ai/code/session_01HvwxjJxDn9eq4HaMz5mrEw