@@ -135,9 +135,6 @@ jobs:
135135 - name : Install dependencies
136136 run : npm ci
137137
138- # Note: Snyk and Semgrep removed to stick with GitHub-native tools only
139- # Dependency vulnerability scanning is handled by npm audit in the security job
140-
141138 # CodeQL Analysis
142139 - name : Initialize CodeQL
143140 uses : github/codeql-action/init@v3
@@ -155,25 +152,18 @@ jobs:
155152 - name : Run custom security checks
156153 run : |
157154 echo "Running custom security checks..."
158-
159- # Check for potential SQL injection patterns
160155 if grep -r "\.query\|\.raw\|\.exec" --include="*.ts" --include="*.js" app/ lib/; then
161156 echo "β οΈ Potential SQL injection patterns found"
162157 echo "Please review the above files for proper parameterization"
163158 fi
164-
165- # Check for potential XSS vulnerabilities
166159 if grep -r "dangerouslySetInnerHTML\|innerHTML" --include="*.tsx" --include="*.jsx" app/ components/; then
167160 echo "β οΈ Potential XSS vulnerabilities found"
168161 echo "Please review the above files for proper sanitization"
169162 fi
170-
171- # Check for hardcoded secrets
172163 if grep -r "password\|secret\|key\|token" --include="*.ts" --include="*.js" --exclude-dir=node_modules --exclude-dir=.git app/ lib/ | grep -v "process\.env"; then
173164 echo "β οΈ Potential hardcoded secrets found"
174165 echo "Please review the above files and use environment variables"
175166 fi
176-
177167 echo "β
Custom security checks completed"
178168
179169 # OWASP ZAP Baseline Scan
@@ -262,20 +252,61 @@ jobs:
262252 - name : Install Vercel CLI
263253 run : npm install -g vercel@latest
264254
255+ - name : Validate Vercel Secrets
256+ run : |
257+ if [ -z "${{ secrets.VERCEL_TOKEN }}" ]; then
258+ echo "β VERCEL_TOKEN is not set"
259+ exit 1
260+ fi
261+ if [ -z "${{ secrets.VERCEL_ORG_ID }}" ]; then
262+ echo "β VERCEL_ORG_ID is not set"
263+ exit 1
264+ fi
265+ if [ -z "${{ secrets.VERCEL_PROJECT_ID }}" ]; then
266+ echo "β VERCEL_PROJECT_ID is not set"
267+ exit 1
268+ fi
269+ echo "β
All Vercel secrets are configured"
270+
271+ - name : Setup Vercel Configuration
272+ run : |
273+ chmod +x scripts/setup-vercel-config.sh
274+ export VERCEL_ORG_ID=${{ secrets.VERCEL_ORG_ID }}
275+ export VERCEL_PROJECT_ID=${{ secrets.VERCEL_PROJECT_ID }}
276+ export VERCEL_TOKEN=${{ secrets.VERCEL_TOKEN }}
277+ ./scripts/setup-vercel-config.sh
278+
279+ - name : Build for Vercel
280+ run : |
281+ npm run build
282+ env :
283+ NODE_ENV : production
284+ NEXT_PUBLIC_SUPABASE_URL : ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
285+ NEXT_PUBLIC_SUPABASE_ANON_KEY : ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
286+ SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
287+
265288 - name : Deploy to Vercel (Staging)
289+ id : deploy-staging
266290 run : |
267- # Remove any existing .vercel directory to avoid conflicts
268- rm -rf .vercel
269- # Deploy directly using scope and project flags
270- vercel --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_ORG_ID }} --project ${{ secrets.VERCEL_PROJECT_ID }} --yes
291+ DEPLOYMENT_URL=$(vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }} --yes)
292+ echo "deployment-url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
293+ echo "π Staging deployment URL: $DEPLOYMENT_URL"
271294 env :
272295 VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
273296 VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
274297
275298 - name : Run smoke tests
276299 run : |
300+ echo "β³ Waiting for deployment to be ready..."
277301 sleep 30
278- curl -f ${{ secrets.STAGING_URL }}/api/health || exit 1
302+ echo "π Testing health endpoint..."
303+ if curl -f -s --max-time 30 "${{ secrets.STAGING_URL }}/api/health"; then
304+ echo "β
Staging health check passed"
305+ else
306+ echo "β Staging health check failed"
307+ echo "Deployment URL: ${{ steps.deploy-staging.outputs.deployment-url }}"
308+ exit 1
309+ fi
279310
280311 # Deploy to Production
281312 deploy-production :
@@ -297,27 +328,68 @@ jobs:
297328 - name : Install Vercel CLI
298329 run : npm install -g vercel@latest
299330
331+ - name : Validate Vercel Secrets
332+ run : |
333+ if [ -z "${{ secrets.VERCEL_TOKEN }}" ]; then
334+ echo "β VERCEL_TOKEN is not set"
335+ exit 1
336+ fi
337+ if [ -z "${{ secrets.VERCEL_ORG_ID }}" ]; then
338+ echo "β VERCEL_ORG_ID is not set"
339+ exit 1
340+ fi
341+ if [ -z "${{ secrets.VERCEL_PROJECT_ID }}" ]; then
342+ echo "β VERCEL_PROJECT_ID is not set"
343+ exit 1
344+ fi
345+ echo "β
All Vercel secrets are configured"
346+
347+ - name : Setup Vercel Configuration
348+ run : |
349+ chmod +x scripts/setup-vercel-config.sh
350+ export VERCEL_ORG_ID=${{ secrets.VERCEL_ORG_ID }}
351+ export VERCEL_PROJECT_ID=${{ secrets.VERCEL_PROJECT_ID }}
352+ export VERCEL_TOKEN=${{ secrets.VERCEL_TOKEN }}
353+ ./scripts/setup-vercel-config.sh
354+
355+ - name : Build for Vercel
356+ run : |
357+ npm run build
358+ env :
359+ NODE_ENV : production
360+ NEXT_PUBLIC_SUPABASE_URL : ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
361+ NEXT_PUBLIC_SUPABASE_ANON_KEY : ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
362+ SUPABASE_SERVICE_ROLE_KEY : ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
363+
300364 - name : Deploy to Vercel (Production)
365+ id : deploy-production
301366 run : |
302- # Remove any existing .vercel directory to avoid conflicts
303- rm -rf .vercel
304- # Deploy directly using scope and project flags
305- vercel --prod --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_ORG_ID }} --project ${{ secrets.VERCEL_PROJECT_ID }} --yes
367+ DEPLOYMENT_URL=$(vercel deploy --prebuilt --prod --token ${{ secrets.VERCEL_TOKEN }} --yes)
368+ echo "deployment-url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT
369+ echo "π Production deployment URL: $DEPLOYMENT_URL"
306370 env :
307371 VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
308372 VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
309373
310374 - name : Run production health check
311375 run : |
376+ echo "β³ Waiting for production deployment to be ready..."
312377 sleep 30
313- curl -f ${{ secrets.PRODUCTION_URL }}/api/health || exit 1
378+ echo "π Testing production health endpoint..."
379+ if curl -f -s --max-time 30 "${{ secrets.PRODUCTION_URL }}/api/health"; then
380+ echo "β
Production health check passed"
381+ else
382+ echo "β Production health check failed"
383+ echo "Deployment URL: ${{ steps.deploy-production.outputs.deployment-url }}"
384+ exit 1
385+ fi
314386
315387 - name : Notify deployment success via email
316388 run : |
317389 curl -X POST "https://api.resend.com/emails" \
318390 -H "Authorization: Bearer ${{ secrets.RESEND_API_KEY }}" \
319391 -H "Content-Type: application/json" \
320- -d "{\"from\":\"alerts@codeunia.com\",\"to\":[\"connect@codeunia.com\"],\"subject\":\"π Production Deployment Successful\",\"html\":\"<h2>Production Deployment Successful</h2><p>Your Codeunia application has been successfully deployed to production.</p><p><strong>Branch:</strong> ${{ github.ref_name }}</p><p><strong>Commit:</strong> ${{ github.sha }}</p><p><strong>Deployed by:</strong> ${{ github.actor }}</p>\"}"
392+ -d "{\"from\":\"alerts@codeunia.com\",\"to\":[\"connect@codeunia.com\"],\"subject\":\"π Production Deployment Successful\",\"html\":\"<h2>Production Deployment Successful</h2><p>Your Codeunia application has been successfully deployed to production.</p><p><strong>Deployment URL:</strong> <a href='${{ steps.deploy-production.outputs.deployment-url }}'>${{ steps.deploy-production.outputs.deployment-url }}</a></p><p><strong> Branch:</strong> ${{ github.ref_name }}</p><p><strong>Commit:</strong> ${{ github.sha }}</p><p><strong>Deployed by:</strong> ${{ github.actor }}</p>\"}"
321393
322394 # Rollback on Failure
323395 rollback :
@@ -330,12 +402,20 @@ jobs:
330402 - name : Checkout code
331403 uses : actions/checkout@v4
332404
405+ - name : Install Vercel CLI
406+ run : npm install -g vercel@latest
407+
408+ - name : Setup Vercel Configuration
409+ run : |
410+ chmod +x scripts/setup-vercel-config.sh
411+ export VERCEL_ORG_ID=${{ secrets.VERCEL_ORG_ID }}
412+ export VERCEL_PROJECT_ID=${{ secrets.VERCEL_PROJECT_ID }}
413+ export VERCEL_TOKEN=${{ secrets.VERCEL_TOKEN }}
414+ ./scripts/setup-vercel-config.sh
415+
333416 - name : Rollback deployment
334417 run : |
335- # Remove any existing .vercel directory to avoid conflicts
336- rm -rf .vercel
337- # Perform rollback using scope flag
338- vercel rollback --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_ORG_ID }} --yes
418+ vercel rollback --token ${{ secrets.VERCEL_TOKEN }} --yes
339419 env :
340420 VERCEL_ORG_ID : ${{ secrets.VERCEL_ORG_ID }}
341421 VERCEL_PROJECT_ID : ${{ secrets.VERCEL_PROJECT_ID }}
0 commit comments