Skip to content

Commit b74bf7f

Browse files
authored
Merge pull request #94 from focusreactive/feature/add-action-to-cleanup-neondb-branch
chore(ci): delete Neon preview branch when PR closes
2 parents 38df7e1 + d83d13e commit b74bf7f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Cleanup Neon preview branch
2+
3+
# The Neon<->Vercel integration creates a `preview/<git-branch>` database branch
4+
# for each apps/cms preview deployment but never removes it. Delete it as soon as
5+
# the PR is closed (merged or not) so stale branches don't accumulate storage costs.
6+
on:
7+
pull_request:
8+
types: [closed]
9+
10+
permissions: {}
11+
12+
jobs:
13+
delete-branch:
14+
name: Delete preview/${{ github.head_ref }}
15+
runs-on: ubuntu-latest
16+
# Fork PRs get no Neon preview branch and cannot read repository secrets.
17+
if: github.event.pull_request.head.repo.full_name == github.repository
18+
steps:
19+
- uses: neondatabase/delete-branch-action@v3
20+
with:
21+
project_id: ${{ secrets.NEON_PROJECT_ID }}
22+
branch: preview/${{ github.head_ref }}
23+
api_key: ${{ secrets.NEON_API_KEY }}

0 commit comments

Comments
 (0)