ci(previews): delete preview charts with branch #26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ci/preview-cleanup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
<version>-pr<N>.<sha>) were never removed, so every PR left packages in the registry. They are now deleted when their branch is.Changes
.gitea/workflows/preview-cleanup.yaml: runs on thedeleteevent (tags ignored) and on manual dispatch (branch,dry_rundefaulting to true).make clean-preview: maps the branch to its PRs throughhead.label, lists container versions matching-pr(<PRs>).<7 hex>, deletes each tag and the untaggedsha256:manifest version it leaves behind. Release versions, other PRs' previews and packages linked to another repository are skipped.$()/backticks in a ref name cannot run commands.Verification
Run against a throwaway Forgejo 15.0.9 container (same version string as git.enclaveis.com), not the live forge:
event: deleterun, loaded from the default branch. Its payload hasref_type: branchandref: refs/heads/<name>(full ref, so the recipe stripsrefs/heads/; this bug was found by that check).head.labelkeeps the branch name after deletion; the PR staysopen(so cleanup does not depend on PR state).pr10/pr100(prefix look-alikes),pr2, the release0.1.0and a package linked to another repo. Re-running is a no-op. The sha256 manifest version is removed with its tag; release/other previews still resolve (HTTP 200).$(touch...), backticks and;, passed through the environment, executed nothing and still matched its own PR.DRY_RUN=falsedeletes;DRY_RUN=1lists. Missing tokens fail with a clear message.actionlint 1.7.7on the workflow: clean.Not verified (no runner available)
github.tokencan list this repo's PRs, thatREGISTRY_TOKENhaswrite:packageand may delete org packages, and that the runner image hasmake,curl,jq.dry_runon.