Skip to content

Run CI on PRs into main and harden the Pages deploy workflow - #7

Draft
mvirgin wants to merge 1 commit into
mainfrom
claude-review/ci-on-main-prs
Draft

mvirgin wants to merge 1 commit into
mainfrom
claude-review/ci-on-main-prs

Conversation

@mvirgin

@mvirgin mvirgin commented Nov 10, 2026

Copy link
Copy Markdown

Summary

The "Pull request checks" workflow only ran on pull requests into production. Every PR in this repo targets main, and production is moved by a direct push or fast-forward, so the lint and build checks have never actually run on a change. The deploy workflow also skipped npm run lint, so a lint error, including a react-hooks rule violation that still compiles, could reach the live course map without anything catching it.

This PR makes CI run where work happens and tightens the deploy workflow:

  • CI now runs lint and build on PRs into main and production and on pushes to both branches.
  • Deploy now lints before building, so a lint failure blocks a release.
  • Deploy is split into an unprivileged build job and a deploy job that only publishes. The deploy job is the only one with the Pages write and OIDC token permissions. Dependency install scripts and the build no longer run alongside those permissions.
  • All actions are pinned to commit SHAs instead of mutable major tags.
  • Deploys queue instead of cancelling a deploy already in progress.

User impact: none on the site itself. Contributors get lint and build feedback on their PRs, and releases are blocked if lint fails.

Changes

  • .github/workflows/ci.yml
    • Triggers on pull_request and push for main and production. Before, only pull_request into production triggered it.
    • Renamed the workflow from "Pull request checks" to "CI" because it now also runs on pushes. The job name "Build and lint" is unchanged, so a required-check rule that uses that name still works.
    • Actions are pinned by SHA. Checkout uses persist-credentials: false because nothing needs to push.
  • .github/workflows/deploy.yml
    • Sets workflow-level permissions: {}. Each job asks only for what it needs.
    • build job (contents: read): checkout, setup-node, npm ci --ignore-scripts, npm run lint, npm run build, then upload the Pages artifact. The only locked dependency with an install script is fsevents, a macOS-only optional dependency that isn't installed on the Linux runner, so --ignore-scripts doesn't change the CI install today. It stops a future or compromised dependency from running code at install time.
    • deploy job (needs: build, pages: write, id-token: write, github-pages environment): only configure-pages and deploy-pages. No repository code or npm packages run in this job.
    • concurrency.cancel-in-progress is now false, which matches GitHub's Pages starter workflow. A second push queues behind a running deploy instead of cancelling it partway.
    • Action pins use the same versions the current major tags point to, so behaviour is unchanged: checkout v4.4.0, setup-node v4.4.0, configure-pages v5.0.0, upload-pages-artifact v3.0.1, deploy-pages v4.0.5. Each pin has a trailing version comment so Dependabot can keep it current once it is configured for github-actions. That config comes from the separate Vite upgrade PR, which adds .github/dependabot.yml. Until it merges, the pins don't update on their own.
  • README.md: new short "Continuous integration and deployment" section. It explains that PRs go to main, merging into main doesn't deploy, and the site deploys from production.

Not changed on purpose: no if: github.ref == 'refs/heads/production' guard was added to the deploy job. The github-pages environment's deployment-branch policy already accepts only production, so a manual run from any other branch is already refused.

Testing

Run locally on Node 22:

  • npm ci --ignore-scripts succeeded. This is the same install command the deploy build job now uses.
  • npm run lint passed with no errors.
  • npm run build (tsc -b && vite build) passed.
  • actionlint (the npm WebAssembly build, actionlint@2.0.6) on ci.yml and deploy.yml reported no problems. As a sanity check, it did flag errors in a deliberately broken workflow.
  • Action SHAs were resolved with git ls-remote against each actions/* repository. They match the commits the current v4/v5/v3 tags point to. None of the tags is annotated, so the SHAs are commit SHAs.

Not tested here (only GitHub can run it):

  • That this PR's own CI run fires. On pull_request events GitHub uses the workflow file from the PR merge ref, so "CI / Build and lint" should show up on this PR. That is the first live check.
  • The split deploy itself, which runs only on a push to production. After the next release, check that both the build and deploy jobs succeed and the site updates at /seaview-interactive-map/.

Merge / deploy notes

Merge this first so the following seaview PRs get CI. Other PRs that are already open only pick up the new trigger on their next push, so push to or rebase them after this merges.

The other seaview PR in this set, the Vite upgrade (claude-review/vite-upgrade), changes package-lock.json and adds .github/dependabot.yml. It touches no files from this PR, and the two branches merge without conflicts. Recommended order: this PR first, then the Vite upgrade, so the Vite upgrade gets a CI run and its Dependabot config starts keeping these action pins current.

Merging into main doesn't deploy. The new deploy workflow first runs on the next push to production, so watch that run.

Optional maintainer follow-ups (repository settings, not code):

  • Add branch protection on main and production that requires the "Build and lint" check. The repo is public, so this is available on the current plan.
  • Keep the github-pages environment limited to production.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@mvirgin
mvirgin requested a review from daltobello November 10, 2026 14:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant