-
Notifications
You must be signed in to change notification settings - Fork 51
50 lines (43 loc) · 1.71 KB
/
deploy-preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Deploy Preview
on:
pull_request:
branches:
- 'develop'
paths-ignore:
- '*.md'
workflow_dispatch:
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: Neon Database Create Branch Action
uses: neondatabase/create-branch-action@v3
id: create_branch
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{ github.event.pull_request.head.ref || github.head_ref }}
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: |
preview_url=$(vercel deploy \
--env DATABASE_URL="${{ steps.create_branch.outputs.db_url_with_pooler}}/neondb?pgbouncer=true&connect_timeout=15&pool_timeout=15" \
--build-env DIRECT_DATABASE_URL="${{ steps.create_branch.outputs.db_url}}/neondb?connect_timeout=10" \
--public --yes --token=${{ secrets.VERCEL_TOKEN }})
echo preview_url=$preview_url >> $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 }}