Repository navigation
ci: delete the Neon preview branch when its pull request closes - #47
Merged
Merged
Conversation
The Vercel-managed Neon integration only removes a preview branch when Vercel deletes the branch's last deployment, which in practice is months or never. With the Free plan's 10-branch limit, stale branches made every new preview deployment fail. This runs Neon's delete-branch-action on PR close, following https://neon.com/docs/guides/vercel-branch-cleanup. Dormant until NEON_PROJECT_ID (variable) and NEON_API_KEY (secret) are set.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Why
Every Vercel preview after #31 failed because the Neon project hit the Free plan's 10-branch limit. The Vercel-managed Neon integration has no "delete when the git branch is deleted" setting. It deletes a preview branch only when Vercel deletes that branch's last deployment. On Hobby that takes 30 days at the earliest, and Vercel always keeps the latest 20 previews, so in a project this size it may never happen. See Neon: Managing Vercel preview branch cleanup.
What
.github/workflows/neon-preview-cleanup.ymlruns Neon'sdelete-branch-actionwhen a PR is closed or merged, deletingpreview/<head branch>(the name the integration uses). The workflow:permissions: {});NEON_PROJECT_IDrepository variable is set, the same pattern asAWS_DEPLOY_ENABLEDindeploy.yml.To turn it on (owner only)
NEON_API_KEYwith that key.NEON_PROJECT_ID=little-field-62303405.The action deletes only the closed PR's own
preview/…branch. It never touchesmain(production).