1+ name : CI/CD Pipeline
2+
3+ on :
4+ push :
5+ branches : [ main, og-image-fixes ]
6+ pull_request :
7+ branches : [ main ]
8+ workflow_dispatch :
9+
10+ # Use least privilege principle
11+ permissions :
12+ contents : read
13+ pull-requests : read
14+ security-events : write
15+ actions : read
16+
17+ env :
18+ NODE_VERSION : ' 20'
19+ BUN_VERSION : ' latest'
20+
21+ jobs :
22+ # Code quality and security checks
23+ quality-checks :
24+ name : Code Quality & Security
25+ runs-on : ubuntu-latest
26+
27+ steps :
28+ - name : Harden Runner
29+ uses : step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
30+ with :
31+ egress-policy : audit
32+
33+ - name : Checkout repository
34+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+ with :
36+ persist-credentials : false
37+
38+ - name : Setup Bun
39+ uses : oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
40+ with :
41+ bun-version : ${{ env.BUN_VERSION }}
42+
43+ - name : Install dependencies
44+ run : bun install --frozen-lockfile
45+
46+ - name : Run code quality checks
47+ run : |
48+ echo "🔍 Running code quality checks..."
49+ bun run check
50+
51+ - name : Security audit (informational)
52+ run : |
53+ echo "🔒 Running security audit..."
54+ bun audit --audit-level high || echo "Security audit completed - review findings above"
55+ continue-on-error : true
56+
57+ # Build verification
58+ build :
59+ name : Build Verification
60+ runs-on : ubuntu-latest
61+ needs : quality-checks
62+
63+ steps :
64+ - name : Harden Runner
65+ uses : step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
66+ with :
67+ egress-policy : audit
68+
69+ - name : Checkout repository
70+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
71+ with :
72+ persist-credentials : false
73+
74+ - name : Setup Bun
75+ uses : oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
76+ with :
77+ bun-version : ${{ env.BUN_VERSION }}
78+
79+ - name : Install dependencies
80+ run : bun install --frozen-lockfile
81+
82+ - name : Build project
83+ run : |
84+ echo "🏗️ Building project..."
85+ bun run build
86+
87+ - name : Verify build output
88+ run : |
89+ echo "✅ Verifying build artifacts..."
90+ [ -d "dist" ] && echo "✅ Build directory exists" || exit 1
91+ [ -f ".vercel/output/config.json" ] && echo "✅ Vercel config generated" || echo "⚠️ Vercel config missing (expected for some builds)"
92+
93+ # Enhanced testing
94+ test :
95+ name : End-to-End Testing
96+ runs-on : ubuntu-latest
97+ needs : build
98+ if : github.event_name == 'pull_request'
99+ continue-on-error : true
100+
101+ steps :
102+ - name : Harden Runner
103+ uses : step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
104+ with :
105+ egress-policy : audit
106+
107+ - name : Checkout repository
108+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
109+ with :
110+ persist-credentials : false
111+
112+ - name : Setup Bun
113+ uses : oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
114+ with :
115+ bun-version : ${{ env.BUN_VERSION }}
116+
117+ - name : Install dependencies
118+ run : bun install --frozen-lockfile
119+
120+ - name : Install Playwright browsers
121+ run : bunx playwright install --with-deps
122+
123+ - name : Run tests
124+ run : |
125+ echo "🧪 Running end-to-end tests..."
126+ bun run test
127+ env :
128+ CI : true
129+
130+ - name : Upload test results
131+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
132+ if : always()
133+ with :
134+ name : playwright-report
135+ path : test-reports/
136+ retention-days : 7
137+
138+ # Security configuration verification
139+ security-config :
140+ name : Security Configuration Check
141+ runs-on : ubuntu-latest
142+
143+ steps :
144+ - name : Harden Runner
145+ uses : step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
146+ with :
147+ egress-policy : audit
148+
149+ - name : Checkout repository
150+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
151+ with :
152+ persist-credentials : false
153+
154+ - name : Verify security middleware
155+ run : |
156+ echo "🔒 Checking security configuration..."
157+
158+ if [ -f "src/middleware/security.ts" ]; then
159+ echo "✅ Security middleware found"
160+
161+ # Check for CSP configuration
162+ if grep -q "Content-Security-Policy" src/middleware/security.ts; then
163+ echo "✅ Content Security Policy configured"
164+ else
165+ echo "❌ Content Security Policy not found"
166+ exit 1
167+ fi
168+
169+ # Check for additional security headers
170+ grep -q "X-Frame-Options" src/middleware/security.ts && echo "✅ X-Frame-Options configured" || echo "⚠️ X-Frame-Options missing"
171+ grep -q "X-Content-Type-Options" src/middleware/security.ts && echo "✅ X-Content-Type-Options configured" || echo "⚠️ X-Content-Type-Options missing"
172+ grep -q "Referrer-Policy" src/middleware/security.ts && echo "✅ Referrer-Policy configured" || echo "⚠️ Referrer-Policy missing"
173+
174+ else
175+ echo "❌ Security middleware not found"
176+ exit 1
177+ fi
178+
179+ # Check for rate limiting
180+ if [ -f "src/middleware/rateLimit.ts" ] || [ -f "src/middleware/advanced-rate-limit.ts" ]; then
181+ echo "✅ Rate limiting middleware found"
182+ else
183+ echo "⚠️ Rate limiting middleware not found"
184+ fi
185+
186+ echo "🔒 Security configuration check completed"
187+
188+ # Deployment readiness (for main branch)
189+ deployment-ready :
190+ name : Deployment Ready
191+ runs-on : ubuntu-latest
192+ needs : [quality-checks, build, security-config]
193+ if : github.ref == 'refs/heads/main'
194+
195+ steps :
196+ - name : Deployment status
197+ run : |
198+ echo "🚀 All checks passed - ready for deployment"
199+ echo "Branch: ${{ github.ref }}"
200+ echo "Commit: ${{ github.sha }}"
201+ echo "Workflow: ${{ github.workflow }}"
0 commit comments