Skip to content

Delete neon branch #222

Delete neon branch

Delete neon branch #222

Workflow file for this run

# Sourced from: https://community.neon.tech/t/delete-vercel-env-vars-when-branch-is-deleted/857/3
name: Delete neon branch
on: delete
jobs:
delete-neon-branch:
if: github.event.ref_type == 'branch'
runs-on: ubuntu-latest
steps:
- name: Get neon branch ID
id: get_branch
run: |
branch=$(curl --silent \
"https://console.neon.tech/api/v2/projects/${{ secrets.NEON_PROJECT_ID }}/branches" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${{ secrets.NEON_API_KEY }}" \
| jq -r .branches \
| jq -c '.[] | select(.name == "preview/${{ github.event.ref }}") .id' \
| jq -r \
) \
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Neon Database Delete Branch
uses: neondatabase/delete-branch-action@dd9e4406f6ce5930915f6de4e52e232f8b776bef # v3.1.5
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch: ${{ steps.get_branch.outputs.branch }}
api_key: ${{ secrets.NEON_API_KEY }}