The Cloudflare credentials are environment secrets, which only resolve for jobs that declare the environment. Deploy moves to its own job bound to the dev environment (with lofi.host as its URL), consuming the build via an artifact; PR builds keep running without any environment or secrets.
- commit
- 4599d84d905e8fb197c5219dd9019459768a85fe
- parent
- 73b04bbd3e42fcec5e6c20b31b797c7c3fd165cb
- author
- Dami <dami.etoile@gmail.com>
| M | .github/ | 26 | ++++++++++++++++++++++++-- |
@@ -39,14 +39,36 @@ jobs:
3939 run: npm ci --prefix website4040 - name: Build site (fails on broken links)4141 run: npm run build --prefix website42+ - name: Upload site build43+ if: github.event_name == 'push'44+ uses: actions/upload-artifact@v445+ with:46+ name: site-build47+ path: website/build48+ retention-days: 149+50+ deploy:51+ if: github.event_name == 'push'52+ needs: build53+ runs-on: ubuntu-latest54+ # the Cloudflare credentials live as secrets on the `dev` environment; a job55+ # must declare that environment for them to resolve56+ environment:57+ name: dev58+ url: https://lofi.host59+ steps:60+ - name: Download site build61+ uses: actions/download-artifact@v462+ with:63+ name: site-build64+ path: site-build4265 # wrangler runs via npx (npm cache) rather than wrangler-action: the action4366 # installs wrangler with `npm i` into the checkout, and npm cannot graft4467 # onto the Deno-managed node_modules layout at the repo root.4568 - name: Deploy to Cloudflare Pages46- if: github.event_name == 'push'4769 env:4870 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}4971 CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}5072 run: |5173 npx --yes wrangler@4 pages project create lofi-host --production-branch=main || true52- npx --yes wrangler@4 pages deploy website/build --project-name=lofi-host74+ npx --yes wrangler@4 pages deploy site-build --project-name=lofi-host --branch=main