ci: reap stale PR previews after deleted branches - #68
Merged
Conversation
Contributor
|
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.
What happened
PR #66 was closed with
--delete-branch. Nopull_requestworkflow run was queued for the close event, sorossjrw/pr-preview-actionnever received its normal removal event andhttps://isaaclins.com/pr-preview/pr-66/stayed live until it was pruned manually. GitHub's merge button deletes the head branch by default, so this is the ordinary path, not an edge case.Fix
pull_requestworkflow and itsclosedcleanup for the normal case where the head branch still exists.pr-preview-reaperplusworkflow_dispatch. It checks everypr-preview/pr-<number>/directory ongh-pagesagainst the pull request API, removes closed or missing PR previews, and makes one commit only when there is something to remove.gh-pages, uses${{ github.token }}, and has explicit path and symlink guards so it cannot removeCNAMEor anything at the branch root. It also supports a manual dry run.The action documentation covers the normal
pull_requestclose event and does not documentpull_request_target.pull_request_targetis unsafe for the existing build job because it would give a write-capable token to code from the pull request, so the deleted-head case is handled by the trusted scheduled reaper instead.pages-deploy.ymlis unchanged.