Skip to content

ci: reap stale PR previews after deleted branches - #68

Merged
isaaclins merged 1 commit into
mainfrom
ci/preview-cleanup
Aug 5, 2026
Merged

ci: reap stale PR previews after deleted branches#68
isaaclins merged 1 commit into
mainfrom
ci/preview-cleanup

Conversation

@isaaclins

Copy link
Copy Markdown
Owner

What happened

PR #66 was closed with --delete-branch. No pull_request workflow run was queued for the close event, so rossjrw/pr-preview-action never received its normal removal event and https://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

  • Keep the existing pull_request workflow and its closed cleanup for the normal case where the head branch still exists.
  • Add a daily pr-preview-reaper plus workflow_dispatch. It checks every pr-preview/pr-<number>/ directory on gh-pages against the pull request API, removes closed or missing PR previews, and makes one commit only when there is something to remove.
  • The reaper checks out only gh-pages, uses ${{ github.token }}, and has explicit path and symlink guards so it cannot remove CNAME or anything at the branch root. It also supports a manual dry run.

The action documentation covers the normal pull_request close event and does not document pull_request_target. pull_request_target is 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.yml is unchanged.

Copilot AI lite review requested due to automatic review settings August 5, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-05 07:39 UTC

@isaaclins
isaaclins merged commit d2207f9 into main Aug 5, 2026
2 checks passed
@isaaclins
isaaclins deleted the ci/preview-cleanup branch August 5, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants