Skip to content

Commit

Permalink
ci: clean preview environment on pr close
Browse files Browse the repository at this point in the history
  • Loading branch information
diego3g committed Mar 3, 2024
1 parent d67e434 commit 9c7c20c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/cleanup-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Clean up Preview

on:
pull_request:
types: [closed]

jobs:
delete-preview:
runs-on: ubuntu-latest
steps:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Delete Neon Branch
uses: neondatabase/[email protected]
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch: preview/pr-${{ github.event.number }}-${{ github.event.pull_request.head.ref }}
api_key: ${{ secrets.NEON_API_KEY }}

- name: Install Vercel CLI
run: pnpm i -g vercel@latest

- name: Delete Vercel Environment Information
run: |
vercel env rm DATABASE_URL preview ${{ steps.branch-name.outputs.current_branch }} --token=${{ secrets.VERCEL_TOKEN }}
vercel env rm DIRECT_DATABASE_URL preview ${{ steps.branch-name.outputs.current_branch }} --token=${{ secrets.VERCEL_TOKEN }}

0 comments on commit 9c7c20c

Please sign in to comment.