1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [main]
6+ pull_request :
7+ branches : [main]
8+
9+ env :
10+ NODE_VERSION : ' 20'
11+ REGISTRY : ghcr.io
12+ IMAGE_NAME : ${{ github.repository }}
13+
14+ jobs :
15+ build :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - name : Checkout code
19+ uses : actions/checkout@v4
20+
21+ - name : Setup pnpm
22+ uses : pnpm/action-setup@v4
23+
24+ - name : Setup Node.js
25+ uses : actions/setup-node@v4
26+ with :
27+ node-version : ${{ env.NODE_VERSION }}
28+ cache : ' pnpm'
29+
30+ - name : Install dependencies
31+ run : pnpm install --frozen-lockfile
32+
33+ - name : Run linting
34+ run : pnpm lint
35+
36+ - name : Build all packages
37+ run : pnpm build
38+
39+ docker-build-and-push :
40+ needs : build
41+ runs-on : ubuntu-latest
42+ permissions :
43+ contents : read
44+ packages : write
45+ if : github.ref == 'refs/heads/main'
46+ steps :
47+ - name : Checkout code
48+ uses : actions/checkout@v4
49+
50+ - name : Set up QEMU
51+ uses : docker/setup-qemu-action@v3
52+
53+ - name : Set up Docker Buildx
54+ uses : docker/setup-buildx-action@v3
55+
56+ - name : Log in to the Container registry
57+ uses : docker/login-action@v3
58+ with :
59+ registry : ${{ env.REGISTRY }}
60+ username : ${{ github.actor }}
61+ password : ${{ secrets.GITHUB_TOKEN }}
62+
63+ - name : Extract metadata (tags, labels) for Docker
64+ id : meta
65+ uses : docker/metadata-action@v5
66+ with :
67+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
68+ tags : |
69+ type=raw,value=latest
70+ type=sha,prefix=,format=long
71+
72+ - name : Build and push Docker image
73+ uses : docker/build-push-action@v6
74+ with :
75+ context : .
76+ push : true
77+ tags : ${{ steps.meta.outputs.tags }}
78+ labels : ${{ steps.meta.outputs.labels }}
79+ cache-from : type=gha
80+ cache-to : type=gha,mode=max
81+
82+ deploy-vercel :
83+ needs : build
84+ runs-on : ubuntu-latest
85+ if : github.ref == 'refs/heads/main'
86+ env :
87+ VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
88+ VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
89+ steps :
90+ - name : Checkout code
91+ uses : actions/checkout@v4
92+
93+ - name : Setup pnpm
94+ uses : pnpm/action-setup@v4
95+
96+ - name : Setup Node.js
97+ uses : actions/setup-node@v4
98+ with :
99+ node-version : ${{ env.NODE_VERSION }}
100+ cache : ' pnpm'
101+
102+ - name : Install Vercel CLI
103+ run : pnpm add -g vercel@latest
104+
105+ - name : Pull Vercel Environment Information
106+ run : vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
107+ working-directory : ./apps/web
108+
109+ - name : Build Project Artifacts
110+ run : vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
111+ working-directory : ./apps/web
112+
113+ - name : Deploy Project Artifacts to Vercel
114+ run : vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
115+ working-directory : ./apps/web
0 commit comments