Skip to content

Adopt gha's cleanup-pr-previews.yml@v2 --- two closed PRs' previews have sat on gh-pages for months #115

Description

@d-morrison

Summary

Adopt Morrison-Lab/gha's cleanup-pr-previews.yml@v2, a scheduled sweep that deletes gh-pages preview directories for PRs that are no longer open. This repo has no such housekeeping today.

Split out of #102 (the full preview-family migration) because this one has no blockers. #102 is held on two upstream gaps (Morrison-Lab/gha#608, #609); the cleanup cron depends on neither --- it reads gh-pages and the PR list and touches nothing the other three legs touch.

Evidence it is needed

The event-based removal in the current hand-rolled preview.yml does not reliably fire. Measured 2026-08-24:

$ gh api "repos/UCD-SERG/ucd-serg.github.io/contents/pr-preview?ref=gh-pages" --jq '.[].name'
pr-107  pr-108  pr-110  pr-111  pr-42  pr-65  pr-76
pr-42: CLOSED  closed=2026-01-10T05:14:52Z
pr-65: MERGED  closed=2026-05-12T06:18:17Z

Both are more than three months stale. Neither is a fork (isCrossRepository=false), and both had closed wired into preview.yml's types: list at the time, so the removal path existed and did not run.

I did not establish the cause. One plausible explanation is that the current workflow renders the whole site before removing, so a render failure blocks the removal --- but that is a hypothesis, not a verified finding, and it should not be treated as one when picking this up.

What to do

  1. Copy gh api "repos/Morrison-Lab/gha/contents/examples/cleanup-pr-previews.yml?ref=v2" into .github/workflows/cleanup-pr-previews.yml.
  2. Grant contents: write and pull-requests: read on the calling job, per gha's permissions table.
  3. Leave preview-dir at its pr-preview default --- that matches what rossjrw/pr-preview-action writes here today.
  4. Decide on compact-history. It orphan-squashes gh-pages to one commit after pruning, so deleted snapshots stop bloating the repo. It is destructive to gh-pages history, so it wants an explicit decision rather than a default; branch-based Pages only, which this repo is.
  5. Note the trigger is schedule + workflow_dispatch, and schedule only fires from the default-branch copy --- so it does nothing until merged. Use workflow_dispatch to test it once it lands.

Scope

Independent of #102 and #103. Safe to land before either.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions