feat(automation): Add CI/CD Pipeline #1
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 | |
| 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 | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| workingDirectory: 'backend' | |
| command: deploy --minify src/index.ts --var SENTRY_RELEASE:$(date +%s) | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| # Source maps are handled by postdeploy script in package.json | |
| - name: Upload Source Maps to Sentry (Post Deploy) | |
| run: npm run postdeploy | |
| working-directory: ./backend | |
| env: | |
| SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
| deploy-frontend: | |
| runs-on: ubuntu-latest | |
| name: Deploy Frontend to Vercel | |
| needs: deploy-backend | |
| 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: 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 |