refactor: replace DEV_BYPASS_SECRET with ENVIRONMENT var and rename ZeroStash to CoverageTracker #33
Workflow file for this run
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 | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'dashboard/**' | |
| - 'migrations/**' | |
| - 'wrangler.json' | |
| - '.github/workflows/deploy.yml' | |
| pull_request: | |
| paths: | |
| - 'src/**' | |
| - 'dashboard/**' | |
| - 'migrations/**' | |
| - 'wrangler.json' | |
| - '.github/workflows/deploy.yml' | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| deploy: | |
| if: github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }} | |
| url: https://demo.coveragetracker.dev | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: '22' | |
| cache: npm | |
| cache-dependency-path: | | |
| package-lock.json | |
| dashboard/package-lock.json | |
| - name: Install root dependencies | |
| run: npm ci | |
| - name: Install dashboard dependencies | |
| working-directory: dashboard | |
| run: npm ci | |
| - name: Inject Database ID into wrangler.json | |
| env: | |
| DB_ID: ${{ secrets.CLOUDFLARE_D1_DATABASE_ID }} | |
| run: | | |
| # Use jq to update the database_id inside the d1_databases array | |
| jq --arg new_val "${DB_ID}" '.env.prod.d1_databases[0].database_id = $new_val' wrangler.json > wrangler.json.tmp | |
| # Replace the old file with the newly updated one | |
| mv wrangler.json.tmp wrangler.json | |
| - name: Deploy Worker + assets | |
| if: github.ref == 'refs/heads/main' | |
| run: npx wrangler deploy --env prod | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |