Skip to content

refactor(NP-87): Add Neon deployment workflows #15

refactor(NP-87): Add Neon deployment workflows

refactor(NP-87): Add Neon deployment workflows #15

Workflow file for this run

name: Deploy Preview
on: [pull_request]
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
deploy-preview:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get PR number
id: get_pull_request_sha
run: |
pull_request_sha=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH" | cut -c1-8)
echo "pull_request_sha=${pull_request_sha}" >> $GITHUB_OUTPUT
echo $pull_request_sha
- name: Neon Database Create Branch Action
uses: neondatabase/create-branch-action@v3
id: create_branch
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{steps.get_pull_request_sha.outputs.pull_request_sha}}
api_key: ${{ secrets.NEON_API_KEY }}
username: ${{ secrets.PG_USERNAME }}
password: ${{ secrets.PG_PASSWORD }}
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Deploy Preview to Vercel
id: deploy
run: |
echo preview_url=$(vercel deploy \
--env DATABASE_URL=${{ steps.create_branch.outputs.db_url_with_pooler}}/neondb \
--build-env DIRECT_DATABASE_URL=${{ steps.create_branch.outputs.db_url}}/neondb \
--public --yes --token=${{ secrets.VERCEL_TOKEN }}) \
>> $GITHUB_OUTPUT
- name: Comment on Pull Request
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Vercel Preview URL :rocket: : ${{ steps.deploy.outputs.preview_url }}
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create_branch.outputs.branch_id }}