1- name : Deploy to Vercel
1+ name : CI & Deploy to Vercel
22
33on :
44 push :
55 branches : [main]
66 pull_request :
77 branches : [main]
88
9+ # Cancel older in-flight runs on the same ref to avoid pile-ups.
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
13+
14+ env :
15+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
16+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
17+
918jobs :
10- build-and-deploy :
19+ # Fast feedback: fails the PR before we burn time on a Vercel build.
20+ ci :
21+ name : Lint + Type-check
1122 runs-on : ubuntu-latest
12-
1323 steps :
1424 - uses : actions/checkout@v4
1525
@@ -28,16 +38,56 @@ jobs:
2838 - name : Type check
2939 run : npx tsc --noEmit
3040
31- - name : Build
32- run : npm run build
33- env :
34- NEXT_PUBLIC_SUPABASE_URL : ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
35- NEXT_PUBLIC_SUPABASE_ANON_KEY : ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
41+ # Preview deploy on pull requests.
42+ deploy-preview :
43+ name : Vercel Preview Deploy
44+ if : github.event_name == 'pull_request'
45+ needs : ci
46+ runs-on : ubuntu-latest
47+ steps :
48+ - uses : actions/checkout@v4
49+
50+ - name : Setup Node.js
51+ uses : actions/setup-node@v4
52+ with :
53+ node-version : 22
54+ cache : npm
55+
56+ - name : Install Vercel CLI
57+ run : npm install --global vercel@latest
58+
59+ - name : Pull Vercel environment (preview)
60+ run : vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
3661
37- - name : Deploy to Vercel
38- uses : amondnet/vercel-action@v25
62+ - name : Build (preview)
63+ run : vercel build --token=${{ secrets.VERCEL_TOKEN }}
64+
65+ - name : Deploy preview
66+ run : vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
67+
68+ # Production deploy on push to main.
69+ deploy-production :
70+ name : Vercel Production Deploy
71+ if : github.event_name == 'push' && github.ref == 'refs/heads/main'
72+ needs : ci
73+ runs-on : ubuntu-latest
74+ steps :
75+ - uses : actions/checkout@v4
76+
77+ - name : Setup Node.js
78+ uses : actions/setup-node@v4
3979 with :
40- vercel-token : ${{ secrets.VERCEL_TOKEN }}
41- vercel-org-id : ${{ secrets.VERCEL_ORG_ID }}
42- vercel-project-id : ${{ secrets.VERCEL_PROJECT_ID }}
43- vercel-args : ' --prod'
80+ node-version : 22
81+ cache : npm
82+
83+ - name : Install Vercel CLI
84+ run : npm install --global vercel@latest
85+
86+ - name : Pull Vercel environment (production)
87+ run : vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
88+
89+ - name : Build (production)
90+ run : vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
91+
92+ - name : Deploy to production
93+ run : vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
0 commit comments