Skip to content

ci: sweep Supabase preview branches older than a week - #1109

Open
charlesyhuang wants to merge 2 commits into
stagingfrom
ci/prune-stale-preview-branches
Open

ci: sweep Supabase preview branches older than a week#1109
charlesyhuang wants to merge 2 commits into
stagingfrom
ci/prune-stale-preview-branches

Conversation

@charlesyhuang

@charlesyhuang charlesyhuang commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Supabase caps the project at 50 active branch projects, and a PR that is abandoned or force-closed never runs the teardown that frees its preview branch, so the pool drains until new PRs cannot provision a preview database at all. This replaces #1054, which tried to recover from the ceiling inline at the moment a PR hit it.

A daily scheduled job now deletes any non-persistent pr-N branch created more than seven days ago; the threshold and a dry-run mode are overridable on manual dispatch. Deletion is recoverable — the PR's next preview run rebuilds the branch from the prod schema snapshot — so a long-lived open PR loses at most one preview rebuild, and an unreadable branch listing fails the sweep before any delete rather than reading as "nothing is stale".


Note

Medium Risk
Deletes live preview infrastructure via the Supabase API on a schedule; mistakes in branch name/age filters could remove active PR previews, though scope is limited to pr-N non-persistent branches and branches can be recreated on the next preview run.

Overview
Adds a scheduled daily sweep (plus manual workflow_dispatch) so abandoned pr-N Supabase preview branches are removed before the project hits its 50 active branch limit, instead of trying to recover at provision time.

The new prune_stale_supabase_branches.sh lists branches, deletes only non-persistent names matching ^pr-[0-9]+$ older than MAX_AGE_DAYS (default 7), supports dry run, validates numeric age, fails the job if any created_at is unparseable, continues after individual delete failures, and redirects stdin on supabase branches delete so the CLI cannot break the delete loop. preview-prune.yml wires secrets/vars through job env (not interpolated into run:).

test_pr_preview_workflow.py gains workflow contract checks and bash integration tests with a fake supabase CLI (filtering, age threshold, dry run, multi-delete regression, timestamp edge cases).

Reviewed by Cursor Bugbot for commit 814fa68. Bugbot is set up for automated code reviews on this repo. Configure here.

Supabase caps the project at 50 active branch projects, and a PR that is
abandoned or force-closed never runs the teardown that frees its preview
branch, so the pool drains until new PRs cannot provision a preview
database at all.

A daily scheduled job now deletes any non-persistent pr-N branch created
more than seven days ago. The threshold and a dry-run mode are
overridable on manual dispatch. Deletion is recoverable: the PR's next
preview run rebuilds the branch from the prod schema snapshot.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
oddish-app Ready Ready Preview Aug 6, 2026 11:41pm

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Oddish preview

Commit: 814fa680ae519df754f25390d15191f2096da92f

Surface Link Target
Frontend https://pr-1109.oddish.app Vercel preview for 814fa68
Backend oddish-pr-1109 oddish-pr-1109
Database project asfaszwycicxtbkkvryo project asfaszwycicxtbkkvryo

Vercel deployment URL: https://oddish-lca8xfpdk.oddish.app

Plan:

  • Frontend deploy: true
  • Backend deploy: true
  • Migrations: true

This comment is updated by the PR Preview workflow.

@cursor cursor Bot 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.

Risk: medium. Approved — Cursor Bugbot passed with no findings requiring human review; Cursor Security Agent was not present. No additional reviewers assigned (reviewers already requested).

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

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.

1 participant