🎉 Add PROJECT_COMPLETION.md - Mission accomplished! #12
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 Contact Form API | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Run unit tests | |
| run: npm run test:unit | |
| - name: Run integration tests | |
| run: npm run test:integration | |
| - name: Generate coverage report | |
| run: npm run test:coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage/lcov.info | |
| flags: unittests | |
| name: codecov-umbrella | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run security audit | |
| run: npm audit --audit-level=moderate | |
| - name: Run dependency check | |
| run: npx depcheck | |
| deploy-staging: | |
| needs: [test, security-scan] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/develop' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Setup Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ env.GCP_PROJECT_ID }} | |
| - name: Deploy to staging | |
| run: | | |
| gcloud functions deploy contact-form-api-staging \ | |
| --runtime nodejs18 \ | |
| --trigger-http \ | |
| --allow-unauthenticated \ | |
| --source=. \ | |
| --entry-point=contactFormHandler \ | |
| --set-env-vars="GCP_PROJECT_ID=${{ env.GCP_PROJECT_ID }},SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }},ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }},FROM_EMAIL=${{ secrets.FROM_EMAIL }},COMPANY_NAME=${{ secrets.COMPANY_NAME }},CORS_ORIGIN=${{ secrets.CORS_ORIGIN_STAGING }}" \ | |
| --max-instances=10 \ | |
| --memory=256MB \ | |
| --timeout=60s | |
| deploy-production: | |
| needs: [test, security-scan] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Setup Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| with: | |
| project_id: ${{ env.GCP_PROJECT_ID }} | |
| - name: Deploy to production | |
| run: | | |
| gcloud functions deploy contact-form-api \ | |
| --runtime nodejs18 \ | |
| --trigger-http \ | |
| --allow-unauthenticated \ | |
| --source=. \ | |
| --entry-point=contactFormHandler \ | |
| --set-env-vars="GCP_PROJECT_ID=${{ env.GCP_PROJECT_ID }},SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }},ADMIN_EMAIL=${{ secrets.ADMIN_EMAIL }},FROM_EMAIL=${{ secrets.FROM_EMAIL }},COMPANY_NAME=${{ secrets.COMPANY_NAME }},CORS_ORIGIN=${{ secrets.CORS_ORIGIN }}" \ | |
| --max-instances=50 \ | |
| --memory=512MB \ | |
| --timeout=60s | |
| - name: Create GitHub Release | |
| if: success() | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ github.run_number }} | |
| release_name: Release v${{ github.run_number }} | |
| body: | | |
| Automated release of contact form API | |
| - Deployed to production | |
| - All tests passed | |
| - Security scan completed | |
| draft: false | |
| prerelease: false |