diff --git a/.github/workflows/cleanup-preview.yml b/.github/workflows/cleanup-preview.yml new file mode 100644 index 0000000..f880ea4 --- /dev/null +++ b/.github/workflows/cleanup-preview.yml @@ -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/delete-branch-action@v3.1.3 + 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 }} +