chore(deps-dev): bump tar from 7.5.10 to 7.5.11 in /frontend (#141) #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🚀 Deploy to Production | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| workflow_dispatch: | |
| inputs: | |
| skip_tests: | |
| description: 'Skip tests (use with caution)' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| env: | |
| NODE_VERSION: '18' | |
| DOCKER_COMPOSE_VERSION: '2.20.0' | |
| jobs: | |
| # Job 1: Code Quality & Security Checks | |
| quality: | |
| name: 🔍 Code Quality & Security | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: | | |
| package-lock.json | |
| frontend/package-lock.json | |
| backend/package-lock.json | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| cd frontend && npm ci --legacy-peer-deps | |
| cd ../backend && npm ci | |
| - name: Lint frontend | |
| run: cd frontend && npm run lint | |
| - name: TypeScript check | |
| run: cd frontend && npx tsc --noEmit | |
| - name: Security audit | |
| run: | | |
| npm audit --audit-level moderate | |
| cd frontend && npm audit --audit-level moderate | |
| cd ../backend && npm audit --audit-level moderate | |
| # Job 2: Testing | |
| test: | |
| name: 🧪 Testing | |
| runs-on: ubuntu-latest | |
| needs: quality | |
| if: inputs.skip_tests != 'true' | |
| services: | |
| postgres: | |
| image: postgres:15-alpine | |
| env: | |
| POSTGRES_PASSWORD: testpassword | |
| POSTGRES_USER: testuser | |
| POSTGRES_DB: testdb | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| cd frontend && npm ci --legacy-peer-deps | |
| cd ../backend && npm ci | |
| - name: Setup test database | |
| env: | |
| DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb | |
| run: | | |
| cd backend | |
| npx prisma migrate dev --name test | |
| npx prisma generate | |
| - name: Run backend tests | |
| env: | |
| DATABASE_URL: postgresql://testuser:testpassword@localhost:5432/testdb | |
| JWT_SECRET: test-secret-key | |
| REDIS_URL: redis://localhost:6379 | |
| run: | | |
| cd backend | |
| node ../test-auth.js | |
| - name: Install Playwright | |
| run: npx playwright install --with-deps chromium | |
| - name: Run Playwright tests | |
| run: npm run test | |
| env: | |
| CI: true | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: playwright-report | |
| path: playwright-report/ | |
| retention-days: 7 | |
| # Job 3: Build & Deploy | |
| deploy: | |
| name: 🚀 Deploy to Production | |
| runs-on: ubuntu-latest | |
| needs: [quality, test] | |
| if: always() && (needs.quality.result == 'success' && (needs.test.result == 'success' || inputs.skip_tests == 'true')) | |
| environment: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create environment file | |
| run: | | |
| cat > .env.production << EOF | |
| NODE_ENV=production | |
| PORT=5001 | |
| DATABASE_URL=postgresql://formbuilder:${{ secrets.DB_PASSWORD }}@postgres:5432/formbuilder | |
| DB_HOST=postgres | |
| DB_PORT=5432 | |
| DB_DATABASE=formbuilder | |
| DB_USER=formbuilder | |
| DB_PASSWORD=${{ secrets.DB_PASSWORD }} | |
| REDIS_URL=redis://redis:6379 | |
| JWT_SECRET=${{ secrets.JWT_SECRET }} | |
| OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} | |
| NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }} | |
| NEXT_PUBLIC_BRAND_PRESET=generic | |
| NEXT_TELEMETRY_DISABLED=1 | |
| SKIP_CONTENTLAYER=false | |
| EOF | |
| - name: Build Docker images | |
| run: | | |
| docker-compose -f docker-compose.prod.yml build --no-cache | |
| - name: Deploy application | |
| run: | | |
| # Set environment variables | |
| export DB_PASSWORD="${{ secrets.DB_PASSWORD }}" | |
| export JWT_SECRET="${{ secrets.JWT_SECRET }}" | |
| export OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}" | |
| export NEXT_PUBLIC_API_URL="${{ secrets.NEXT_PUBLIC_API_URL }}" | |
| # Run deployment script | |
| ./scripts/deploy.sh | |
| - name: Health check | |
| run: | | |
| timeout 300 bash -c 'while ! curl -f http://localhost:5001/health; do sleep 5; done' | |
| curl -f http://localhost:3000 > /dev/null | |
| - name: Notify deployment status | |
| if: always() | |
| run: | | |
| if [ "${{ job.status }}" = "success" ]; then | |
| echo "✅ Deployment successful!" | |
| echo "🌐 Application: http://localhost:3000" | |
| echo "⚙️ API: http://localhost:5001" | |
| else | |
| echo "❌ Deployment failed!" | |
| fi | |
| # Job 4: Post-deployment tests | |
| smoke-tests: | |
| name: 🚨 Smoke Tests | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| if: always() && needs.deploy.result == 'success' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run smoke tests | |
| run: | | |
| # Test critical endpoints | |
| curl -f http://localhost:5001/health | |
| curl -f http://localhost:3000 | |
| # Test authentication | |
| response=$(curl -s -X POST http://localhost:5001/api/v1/auth/register \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"email":"smoke-test@example.com","password":"testpass123","name":"Smoke Test"}') | |
| if echo "$response" | grep -q "success"; then | |
| echo "✅ Authentication system working" | |
| else | |
| echo "❌ Authentication system failed" | |
| exit 1 | |
| fi | |
| - name: Performance check | |
| run: | | |
| # Basic performance check | |
| response_time=$(curl -o /dev/null -s -w '%{time_total}' http://localhost:3000) | |
| if (( $(echo "$response_time < 3.0" | bc -l) )); then | |
| echo "✅ Performance check passed: ${response_time}s" | |
| else | |
| echo "⚠️ Performance warning: ${response_time}s (>3s)" | |
| fi |