ci: prune pr-build/* branches for closed PRs on trunk pushes#496
Closed
ci: prune pr-build/* branches for closed PRs on trunk pushes#496
pr-build/* branches for closed PRs on trunk pushes#496Conversation
Each PR build force-pushes a `pr-build/<n>` snapshot branch. Nothing prunes them, so they accumulate. Add a Buildkite step that runs on trunk pushes, lists `pr-build/*` refs, queries each PR's state via the GitHub API, and deletes the refs whose PR is `closed` (covers both merged and rejected — GitHub collapses them). Skips a branch on any non-200 response so we never delete a ref we couldn't verify. Mirrors the wordpress-rs sweep step.
Contributor
Author
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.
Summary
pr-build/<n>snapshot branch (ci(ios): publish + prune per-PR XCFramework snapshot branches #495). Nothing prunes them, so they accumulate.pr-build/*refs, queries each PR's state via the GitHub API, and deletes the refs whose PR isclosed(covers both merged and rejected — GitHub collapses them).Changes
.buildkite/cleanup-pr-build-branches.sh(new): Guards onBUILDKITE_BRANCH == "trunk", sourcesuse-bot-for-git, enumerates viagit ls-remote --heads origin 'refs/heads/pr-build/*', queriesGET /repos/wordpress-mobile/GutenbergKit/pulls/<n>withGITHUB_TOKEN, and deletes closed-PR refs with batchedgit push origin :refs/heads/...(chunks of 50). Skips on non-200 responses so we never delete a ref we couldn't verify..buildkite/pipeline.yml: New step gated tobuild.branch == "trunk", sharing the standard*pluginsanchor (CI toolkit + NVM).Test plan
pr-build/*branches accumulated from ci(ios): publish + prune per-PR XCFramework snapshot branches #495 testing.pr-build/<n>branch.pr-build/*branches are left alone.Related
pr-build/*branches exist in the first place.