-
Notifications
You must be signed in to change notification settings - Fork 577
89 lines (73 loc) · 2.58 KB
/
vercel-auto-deploy.yml
File metadata and controls
89 lines (73 loc) · 2.58 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Vercel Auto Deploy (Preview & Production)
on:
push:
branches: ["**"]
pull_request:
types: [opened, synchronize, reopened]
jobs:
deploy-preview:
if: github.event_name == 'pull_request' || github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Vercel CLI
run: npm i -g vercel@latest
- name: Pull Vercel Environment Info (preview)
run: vercel pull --yes --environment=preview --token "$VERCEL_TOKEN"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Build (preview)
run: vercel build --token "$VERCEL_TOKEN"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- name: Deploy (preview)
id: deploy_preview
run: |
url=$(vercel deploy --prebuilt --token "$VERCEL_TOKEN" --yes)
echo "preview_url=$url" >> $GITHUB_OUTPUT
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- name: Output Preview URL
run: echo "Preview URL: ${{ steps.deploy_preview.outputs.preview_url }}"
deploy-production:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install Vercel CLI
run: npm i -g vercel@latest
- name: Pull Vercel Environment Info (production)
run: vercel pull --yes --environment=production --token "$VERCEL_TOKEN"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Build (production)
run: vercel build --prod --token "$VERCEL_TOKEN"
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- name: Deploy (production)
id: deploy_prod
run: |
url=$(vercel deploy --prebuilt --prod --token "$VERCEL_TOKEN" --yes)
echo "prod_url=$url" >> $GITHUB_OUTPUT
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
- name: Output Production URL
run: echo "Production URL: ${{ steps.deploy_prod.outputs.prod_url }}"