N
Neon16mo ago
deep-jade

Neon Github action for deleting a branch is flakey

I have the following github action script, and often times the delete-branch step fails
name: Neon Testing
on: push

jobs:
neon-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true

# Doppler setup
- name: Setup Doppler
uses: dopplerhq/secrets-fetch-action@v1.2.0
id: doppler
with:
doppler-token: ${{ secrets.DOPPLER_CI_SERVICE_TOKEN }}
inject-env-vars: true

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
registry-url: 'https://npm.pkg.github.com'

- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Neon Feature Branch
uses: neondatabase/create-branch-action@v5
id: create-feat-branch
with:
project_id: xxxxxxx
database: xxxxxxx
username: xxxxxxx
branch_name: ${GITHUB_REF_NAME}
api_key: ${{ secrets.NEON_API_KEY }}

- name: Set Neon Branch ID
run: echo "NEON_BRANCH_ID=${{ steps.create-feat-branch.outputs.branch_id }}" >> $GITHUB_ENV;

- name: Set Neon Database URL for Testing
run: echo "NEON_DATABASE_URL=${{ steps.create-feat-branch.outputs.db_url }}?sslmode=require" >> $GITHUB_ENV;

- name: Integration Test Against New Neon Branch
run: yarn test:integ
env:
IS_TEST: true

- name: Delete Feature Branch
if: always()
uses: neondatabase/delete-branch-action@v3
id: delete-feature-branch
with:
project_id: xxxxxxx
branch: ${{ env.NEON_BRANCH_ID }}
api_key: ${{ secrets.NEON_API_KEY }}
name: Neon Testing
on: push

jobs:
neon-testing:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
lfs: true

# Doppler setup
- name: Setup Doppler
uses: dopplerhq/secrets-fetch-action@v1.2.0
id: doppler
with:
doppler-token: ${{ secrets.DOPPLER_CI_SERVICE_TOKEN }}
inject-env-vars: true

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
registry-url: 'https://npm.pkg.github.com'

- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Create Neon Feature Branch
uses: neondatabase/create-branch-action@v5
id: create-feat-branch
with:
project_id: xxxxxxx
database: xxxxxxx
username: xxxxxxx
branch_name: ${GITHUB_REF_NAME}
api_key: ${{ secrets.NEON_API_KEY }}

- name: Set Neon Branch ID
run: echo "NEON_BRANCH_ID=${{ steps.create-feat-branch.outputs.branch_id }}" >> $GITHUB_ENV;

- name: Set Neon Database URL for Testing
run: echo "NEON_DATABASE_URL=${{ steps.create-feat-branch.outputs.db_url }}?sslmode=require" >> $GITHUB_ENV;

- name: Integration Test Against New Neon Branch
run: yarn test:integ
env:
IS_TEST: true

- name: Delete Feature Branch
if: always()
uses: neondatabase/delete-branch-action@v3
id: delete-feature-branch
with:
project_id: xxxxxxx
branch: ${{ env.NEON_BRANCH_ID }}
api_key: ${{ secrets.NEON_API_KEY }}
No description
6 Replies
stormy-gold
stormy-gold16mo ago
That's strange, the error looks like ${{ env.NEON_BRANCH_ID }} contains no value. Can you double check that it's being written?
deep-jade
deep-jadeOP16mo ago
The branch itself is being created
flat-fuchsia
flat-fuchsia16mo ago
What happens if you use the branch_id from the create branch action step instead of adding the variable to the GitHub Env? So in your case you would do ${{ steps.create-feat-branch.outputs.branch_id }}
deep-jade
deep-jadeOP16mo ago
actually curious if i can get rid of the delete-branch-action step altogether. Does the create-branch-action automatically handle branch cleanup?
flat-fuchsia
flat-fuchsia16mo ago
Does the create-branch-action automatically handle branch cleanup?
It doesn't
stormy-gold
stormy-gold16mo ago
We are planning on a new action that would manage branch cleanup and creation in the same action

Did you find this page helpful?