Skip to content

templates: deploy pull request previews from a job that runs no notebook code, and stop persisting checkout credentials #232

Closed

Description

@mmcky

From the 2026-10-06 codebase review (finding M1; record: .qe/dev/log/2026-10-06-codebase-review.md, #220).

Problem

Building the lectures runs code the repository does not fully control: notebook cells, including packages installed at build time, and network fetches. In templates/ci.yml that code runs in the same job, and the same container, as the later step that hands the Netlify (or Cloudflare) token to the deploy CLI (templates/ci.yml:77-96). Code that runs earlier in a job can affect the steps after it. So a compromised build dependency, on a pull request from a branch of the repository, shares a job with a long-lived deploy credential. Fork and Dependabot pull requests are not exposed: they get no secrets, and the preview actions skip them.

Separately, no template sets persist-credentials: false on actions/checkout (templates/ci.yml:46-47, templates/cache.yml:59-64, templates/publish.yml:55-60). The job token therefore stays available to build code for the whole job. This repository's own harness gate sets persist-credentials: false for that reason.

Proposal

  • Set persist-credentials: false on the checkout in all three templates. cache.yml and publish.yml run only local git log afterwards.
  • Split ci.yml into two jobs:
    • Build: runs in the container with contents: read, builds the site, and uploads _build/html as an artifact.
    • Deploy: needs: the build job and needs no container. It holds pull-requests: write and the provider secret, checks out with persist-credentials: false, downloads the artifact, and runs preview-netlify (or preview-cloudflare). It never runs jb build or any repository script.
  • Keep change detection working. scripts/detect-changed-lectures.sh fetches the base and head commits after a depth-1 checkout. Confirm it still lists the changed lectures without persisted credentials (a public repository fetches anonymously), and state what a private repository needs.
  • Update the template comments, docs/user/actions/preview-netlify.md, docs/user/actions/preview-cloudflare.md and CHANGELOG.md.

Done when

  • All three templates check out with persist-credentials: false.
  • templates/ci.yml deploys the preview from a job that runs no repository code, and the preview comment still links the changed lectures.
  • The manual shows the two-job shape, and the harness's example check (scripts/generate-docs.py --check-examples with actionlint) passes on the new template.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementsecurity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions