Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/neon-preview-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Neon preview branch cleanup

# The Vercel-managed Neon integration creates a database branch `preview/<git branch>` for every preview deployment,
# but only deletes it when Vercel deletes that branch's last deployment, which can take months or never happen
# (Vercel keeps the latest 20 previews). The Free plan allows 10 branches per project, and once they are used up,
# every new preview deployment fails. This deletes the preview branch as soon as its pull request is closed or merged.
# See https://neon.com/docs/guides/vercel-branch-cleanup
#
# Dormant until configured: set the repository variable NEON_PROJECT_ID and the repository secret NEON_API_KEY.

on:
pull_request:
types: [closed]

permissions: {}

jobs:
delete-preview-branch:
if: vars.NEON_PROJECT_ID != ''
runs-on: ubuntu-latest
steps:
- uses: neondatabase/delete-branch-action@v3
# A PR whose preview never got a database branch has nothing to delete; that is not a failure.
continue-on-error: true
with:
project_id: ${{ vars.NEON_PROJECT_ID }}
branch: preview/${{ github.head_ref }}
api_key: ${{ secrets.NEON_API_KEY }}
Loading