Update deploy.yml #8
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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| deploy-backend: | |
| runs-on: ubuntu-latest | |
| name: Deploy Backend to Cloudflare | |
| environment: Production | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: './backend/package-lock.json' | |
| - name: Install Backend Dependencies | |
| run: npm ci | |
| working-directory: ./backend | |
| - name: Run Backend Tests | |
| run: npm run test:run | |
| working-directory: ./backend | |
| - name: Deploy to Cloudflare Workers | |
| run: npm run deploy | |
| working-directory: ./backend | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| SENTRY_DSN: ${{ secrets.SENTRY_DSN }} | |
| SUPABASE_JWT_SECRET: ${{ secrets.SUPABASE_JWT_SECRET }} | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| DIRECT_DATABASE_URL: ${{ secrets.DIRECT_DATABASE_URL }} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| name: Deploy Frontend to Vercel | |
| needs: deploy-backend | |
| environment: Production | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: './frontend/package-lock.json' | |
| - name: Install Frontend Dependencies | |
| run: npm ci | |
| working-directory: ./frontend | |
| - name: Run Frontend Tests | |
| run: npm run test:run | |
| working-directory: ./frontend | |
| - name: Build Frontend | |
| run: npm run build | |
| working-directory: ./frontend | |
| # - name: Upload Source Maps to Sentry | |
| # run: npx @sentry/cli sourcemaps inject --org sumitbhuia --project medium-clone-frontend ./dist && npx @sentry/cli sourcemaps upload --org sumitbhuia --project medium-clone-frontend ./dist | |
| # working-directory: ./frontend | |
| # env: | |
| # SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| - name: Deploy to Vercel | |
| uses: amondnet/vercel-action@v25 | |
| with: | |
| vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
| vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
| vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
| working-directory: ./frontend |