Skip to content

Commit 7412abc

Browse files
author
Deepak Pandey
committed
fix: Resolve CI/CD errors and add Vercel bypass token support
πŸ”§ Fixes implemented: 1. βœ… Lighthouse CI GitHub token issue - Added LHCI_TOKEN environment variable 2. βœ… Next.js build issue in security testing - Added proper build logging and increased sleep time 3. βœ… Vercel deployment protection bypass - Added VERCEL_BYPASS_TOKEN support for health checks 🎯 Health check improvements: - Uses bypass token when available to access protected deployments - Falls back gracefully when bypass token is not configured - Maintains security while enabling CI/CD automation This resolves the 401 authentication errors and build failures in the CI/CD pipeline.
1 parent 0c8c833 commit 7412abc

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

β€Ž.github/workflows/ci-cd.ymlβ€Ž

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,12 @@ jobs:
172172
# Start Next.js app for security testing
173173
- name: Start Next.js app
174174
run: |
175+
echo "Building Next.js app for security testing..."
175176
npm run build
177+
echo "Starting Next.js production server..."
176178
npm run start &
177-
sleep 10
179+
echo "Waiting for app to start..."
180+
sleep 15
178181
env:
179182
NODE_ENV: production
180183
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
@@ -462,12 +465,27 @@ jobs:
462465
463466
# Try main health check with quick parameter (bypasses complex checks)
464467
echo "Testing main health check (quick mode): $DEPLOYMENT_URL/api/health?quick=true"
465-
if curl -f -s --max-time 30 "$DEPLOYMENT_URL/api/health?quick=true"; then
468+
# Add bypass token if available
469+
if [ -n "${{ secrets.VERCEL_BYPASS_TOKEN }}" ]; then
470+
HEALTH_URL="$DEPLOYMENT_URL/api/health?quick=true&x-vercel-set-bypass-cookie=true&x-vercel-protection-bypass=${{ secrets.VERCEL_BYPASS_TOKEN }}"
471+
echo "Using bypass token for health check"
472+
else
473+
HEALTH_URL="$DEPLOYMENT_URL/api/health?quick=true"
474+
echo "No bypass token available"
475+
fi
476+
477+
if curl -f -s --max-time 30 "$HEALTH_URL"; then
466478
echo "βœ… Main health check passed (quick mode)"
467479
else
468480
echo "❌ Quick health check failed, trying full health check..."
469481
echo "Testing full health check: $DEPLOYMENT_URL/api/health"
470-
if curl -f -s --max-time 60 "$DEPLOYMENT_URL/api/health"; then
482+
# Try full health check with bypass token
483+
if [ -n "${{ secrets.VERCEL_BYPASS_TOKEN }}" ]; then
484+
FULL_HEALTH_URL="$DEPLOYMENT_URL/api/health&x-vercel-set-bypass-cookie=true&x-vercel-protection-bypass=${{ secrets.VERCEL_BYPASS_TOKEN }}"
485+
else
486+
FULL_HEALTH_URL="$DEPLOYMENT_URL/api/health"
487+
fi
488+
if curl -f -s --max-time 60 "$FULL_HEALTH_URL"; then
471489
echo "βœ… Full health check passed"
472490
else
473491
echo "❌ Full health check also failed"
@@ -575,6 +593,7 @@ jobs:
575593
lhci autorun
576594
env:
577595
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
596+
LHCI_TOKEN: ${{ secrets.LHCI_TOKEN }}
578597

579598
- name: Upload performance results
580599
uses: actions/upload-artifact@v4

0 commit comments

Comments
Β (0)