Skip to content

feat(ci): reconcile previews that outlived their pull request - #1461

Merged
FelixTJDietrich merged 1 commit into
mainfrom
feat/reconcile-orphaned-previews
Aug 21, 2026
Merged

feat(ci): reconcile previews that outlived their pull request#1461
FelixTJDietrich merged 1 commit into
mainfrom
feat/reconcile-orphaned-previews

Conversation

@FelixTJDietrich

Copy link
Copy Markdown
Collaborator

Description

cleanup-preview.yml deletes a preview when its pull request closes. That is the fast path, and it works — but it is also the only path, and it has three silent holes:

  • it exits without doing anything when COOLIFY_API_TOKEN is unset;
  • it never runs for a fork pull request;
  • it cannot reach Coolify if Coolify is down at that moment.

Nothing afterwards notices. A preview that outlives its pull request keeps a cloned database and a git checkout — roughly 4 GB — until someone goes looking, which is exactly how the last orphan was found.

What changes

A scheduled job that asks the opposite question daily: of the pull requests that closed recently, does any still have a preview? For each, it issues the same idempotent delete the cleanup workflow does. An already-clean pull request answers 404 and costs one request; open pull requests are never touched.

Reclaiming anything is reported as a warning with the pull request number, and lands in the job summary. That is deliberate: a reconciler that quietly fixes the same leak every night is hiding a broken cleanup path, and the point is to see it.

Defaults to a 45-day window, overridable on manual dispatch. No new secrets — it reuses the Coolify variables the cleanup workflow already has, and skips itself with a notice if they are absent.

How to test

date -d is GNU-only, so I extracted the step script and ran it on a Linux host against a stubbed Coolify and pull request list, covering all three paths:

Scenario Result
Preview already gone (404) silent, not counted
Orphan found (200) checked=2 reclaimed=1 failed=0, warning raised, summary row written
Coolify error (500) error annotation, summary row, exit 1
Window filtering a pull request closed 228 days ago is excluded at 45 days, included at 300
COOLIFY_API_TOKEN unset notice, exit 0

The gh pr list --jq query was run against this repository for real and returns the expected number closedAt pairs.

Checklist

  • My changeset summary reads as an operator/user-facing note (it becomes the changelog entry) — see .changeset/README.md
  • If the operator must act on this change (new required env var, manual migration step), the changeset summary says how (**Operators:** …) and MIGRATION.md is updated

No changeset: this adds a CI workflow only. Nothing under server/, webapp/ or docker/ changes, so there is no operator- or user-visible effect to describe.

Cleanup on close is the fast path and it is also the only path. It exits
without doing anything when COOLIFY_API_TOKEN is unset, it never runs for a
fork, and it cannot reach Coolify if Coolify is down at that moment.
Nothing afterwards notices, so a preview that outlives its pull request
keeps a cloned database and a git checkout — roughly 4 GB — until someone
goes looking, which is how the last one was found.

This asks the opposite question daily: of the pull requests that closed
recently, does any still have a preview? Deleting one is idempotent, so an
already-clean pull request answers 404 and costs a request. Open pull
requests are never touched, and reclaiming anything is reported as a
warning rather than absorbed silently — a reconciler that quietly fixes the
same leak every night is hiding a broken cleanup path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZADQeSx6zQNNqsdu7AAqZ
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@FelixTJDietrich, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 59 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 07e778c9-741b-47c4-9794-07ca0537ec1e

📥 Commits

Reviewing files that changed from the base of the PR and between 7b03a84 and 7a67130.

📒 Files selected for processing (1)
  • .github/workflows/reconcile-previews.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added feature New feature or enhancement ci GitHub Actions, workflows, build pipeline changes size:L This PR changes 100-499 lines, ignoring generated files. labels Aug 21, 2026
@FelixTJDietrich
FelixTJDietrich merged commit 37a1537 into main Aug 21, 2026
48 checks passed
@FelixTJDietrich
FelixTJDietrich deleted the feat/reconcile-orphaned-previews branch August 21, 2026 14:58
@github-actions

Copy link
Copy Markdown
Contributor

📚 Documentation Preview

Preview has been removed (PR closed)

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

Labels

ci GitHub Actions, workflows, build pipeline changes feature New feature or enhancement size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant