From bd8d564ec13e9fa2af226a243df7c1c845b2b72e Mon Sep 17 00:00:00 2001 From: mvirgin Date: Tue, 10 Nov 2026 09:39:09 -0500 Subject: [PATCH] Run CI on PRs into main and harden deploy workflow Trigger the build-and-lint workflow on pull requests and pushes for main and production; it previously ran only on PRs into production, which no PR has ever targeted. Split the Pages deploy into an unprivileged build job (now also runs lint and installs with --ignore-scripts) and a deploy job that is the only one holding pages/id-token write. Pin all actions to commit SHAs and stop cancelling in-progress deploys. Document the main-to-production release flow in the README. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 12 ++++++---- .github/workflows/deploy.yml | 46 +++++++++++++++++++++++------------- README.md | 5 ++++ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b84b5e0..0564ad3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,10 @@ -name: Pull request checks +name: CI on: pull_request: - branches: [production] + branches: [main, production] + push: + branches: [main, production] permissions: contents: read @@ -13,9 +15,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false - - uses: actions/setup-node@v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8eceaa1..a2b85c6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,39 +5,53 @@ on: branches: [production] workflow_dispatch: -permissions: - contents: read - pages: write - id-token: write +# No default token permissions; each job requests only what it needs. +permissions: {} +# Queue deploys instead of cancelling one mid-deploy. concurrency: group: pages - cancel-in-progress: true + cancel-in-progress: false jobs: - deploy: + # Unprivileged: installs dependencies, lints, builds and uploads the site. + build: runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} + permissions: + contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false - - uses: actions/setup-node@v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: npm - - run: npm ci + - run: npm ci --ignore-scripts + - run: npm run lint - run: npm run build - - uses: actions/configure-pages@v5 - - - uses: actions/upload-pages-artifact@v3 + - uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: dist + # Privileged: only publishes the artifact built above. + deploy: + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - name: Deploy id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/README.md b/README.md index 49aa78f..2fddcce 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,8 @@ Open the local URL printed by Vite in your browser. - `src/data/map.ts`: loads the bundled SVG map. - `src/assets/`: map artwork, persona portraits, and landmark imagery. +## Continuous integration and deployment + +- `.github/workflows/ci.yml` runs `npm run lint` and `npm run build` on every pull request into `main` or `production` and on every push to those branches. +- Open pull requests against `main`. Merging into `main` does not deploy. +- The live site deploys from the `production` branch. `.github/workflows/deploy.yml` runs on each push to `production` (or a manual run from `production`), lints and builds the app in an unprivileged job, then publishes `dist/` to GitHub Pages in a separate job. To release, fast-forward `production` to `main` after CI passes on `main`.