-
Notifications
You must be signed in to change notification settings - Fork 1
98 lines (77 loc) · 2.45 KB
/
preview.yml
File metadata and controls
98 lines (77 loc) · 2.45 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
89
90
91
92
93
94
95
96
97
98
name: Preview
on:
pull_request:
branches: ['develop']
permissions:
contents: read
pull-requests: write
concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup Node with npm cache (package-lock.json)
- name: Setup Node (npm cache)
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Show versions
run: |
node -v
npm -v
- name: Install dependencies
run: npm ci
- name: Lint (if present)
run: npm run --if-present lint
- name: Typecheck (if present)
run: npm run --if-present typecheck
- name: Test (if present)
run: npm run --if-present test -- --passWithNoTests
- name: Build
run: npm run build
vercel-preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft }}
needs: checks
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- name: Setup Node (npm cache)
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Show versions
run: |
node -v
npm -v
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Env (preview)
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts (prebuilt)
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Preview
id: deploy
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
run: |
url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
echo "preview_url=$url" >> $GITHUB_OUTPUT
- name: Comment PR with Preview URL
uses: thollander/actions-comment-pull-request@v2
with:
message: |
✅ PREVIEW: ${{ steps.deploy.outputs.preview_url }}