1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - develop
8+ pull_request :
9+ branches :
10+ - main
11+ - develop
12+
13+ env :
14+ NODE_VERSION : 18
15+
16+ jobs :
17+ lint-and-type-check :
18+ name : Lint and Type Check
19+ runs-on : ubuntu-latest
20+ steps :
21+ - name : Checkout code
22+ uses : actions/checkout@v4
23+ - name : Setup Node.js
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : ${{ env.NODE_VERSION }}
27+ cache : ' yarn'
28+ - name : Install dependencies
29+ run : yarn install --frozen-lockfile
30+ - name : Run ESLint
31+ run : yarn lint
32+ - name : Run TypeScript type check
33+ run : yarn tsc --noEmit
34+
35+ test :
36+ name : Test
37+ runs-on : ubuntu-latest
38+ needs : lint-and-type-check
39+ steps :
40+ - name : Checkout code
41+ uses : actions/checkout@v4
42+ - name : Setup Node.js
43+ uses : actions/setup-node@v4
44+ with :
45+ node-version : ${{ env.NODE_VERSION }}
46+ cache : ' yarn'
47+ - name : Install dependencies
48+ run : yarn install --frozen-lockfile
49+ - name : Run tests
50+ run : yarn test
51+ env :
52+ CI : true
53+
54+ build :
55+ name : Build
56+ runs-on : ubuntu-latest
57+ needs : [lint-and-type-check, test]
58+ steps :
59+ - name : Checkout code
60+ uses : actions/checkout@v4
61+ - name : Setup Node.js
62+ uses : actions/setup-node@v4
63+ with :
64+ node-version : ${{ env.NODE_VERSION }}
65+ cache : ' yarn'
66+ - name : Install dependencies
67+ run : yarn install --frozen-lockfile
68+ - name : Build application
69+ run : yarn build
70+ env :
71+ NEXT_PUBLIC_SUPABASE_URL : ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
72+ NEXT_PUBLIC_SUPABASE_ANON_KEY : ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
73+ NEXT_PUBLIC_SITE_URL : ${{ secrets.NEXT_PUBLIC_SITE_URL }}
74+ - name : Upload build artifacts
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : build-files
78+ path : .next/
79+ retention-days : 1
80+
81+ security-scan :
82+ name : Security Scan
83+ runs-on : ubuntu-latest
84+ needs : build
85+ steps :
86+ - name : Checkout code
87+ uses : actions/checkout@v4
88+ - name : Setup Node.js
89+ uses : actions/setup-node@v4
90+ with :
91+ node-version : ${{ env.NODE_VERSION }}
92+ cache : ' yarn'
93+ - name : Install dependencies
94+ run : yarn install --frozen-lockfile
95+ - name : Run security audit
96+ run : yarn audit --audit-level moderate
97+
98+ docker :
99+ name : Docker Build
100+ runs-on : ubuntu-latest
101+ needs : build
102+ steps :
103+ - name : Checkout code
104+ uses : actions/checkout@v4
105+ - name : Set up Docker Buildx
106+ uses : docker/setup-buildx-action@v3
107+ - name : Build Docker image
108+ run : |
109+ docker build -t collaborative-platform:test .
110+ docker run --rm collaborative-platform:test yarn build
0 commit comments