@@ -3,27 +3,72 @@ name: Deploy to Vercel
33on :
44 push :
55 branches : [main]
6+ pull_request :
7+ branches : [main]
68
79jobs :
810 deploy :
911 runs-on : ubuntu-latest
1012
1113 steps :
12- - uses : actions/checkout@v4
14+ - name : Checkout code
15+ uses : actions/checkout@v4
1316
1417 - name : Setup Node.js
1518 uses : actions/setup-node@v4
1619 with :
1720 node-version : ' 22'
18- cache : ' pnpm'
1921
20- - name : Install dependencies
21- run : pnpm install
22+ - name : Setup pnpm
23+ uses : pnpm/action-setup@v4
24+ with :
25+ version : 8
26+ run_install : false
2227
23- - name : Deploy to Vercel
24- uses : amondnet/vercel-action@v25
28+ - name : Get pnpm store directory
29+ shell : bash
30+ run : |
31+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+ - name : Setup pnpm cache
34+ uses : actions/cache@v4
2535 with :
26- vercel-token : ${{ secrets.VERCEL_TOKEN }}
27- vercel-org-id : ${{ secrets.VERCEL_ORG_ID }}
28- vercel-project-id : ${{ secrets.VERCEL_PROJECT_ID }}
29- vercel-args : ' --prod'
36+ path : ${{ env.STORE_PATH }}
37+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+ restore-keys : |
39+ ${{ runner.os }}-pnpm-store-
40+
41+ - name : Install dependencies
42+ run : pnpm install --frozen-lockfile
43+
44+ - name : Build project
45+ run : pnpm run build
46+
47+ - name : Install Vercel CLI
48+ run : pnpm add --global vercel@latest
49+
50+ - name : Pull Vercel Environment Information
51+ run : vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
52+ env :
53+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
54+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
55+
56+ - name : Build Project Artifacts
57+ run : vercel build --token=${{ secrets.VERCEL_TOKEN }}
58+ env :
59+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
60+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
61+
62+ - name : Deploy Project Artifacts to Vercel
63+ run : vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
64+ env :
65+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
66+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
67+
68+ # Deploy to production on main/master branch
69+ - name : Deploy to Production
70+ if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
71+ run : vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
72+ env :
73+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
74+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
0 commit comments