Skip to content

ci(docs): build the site on pull requests, deploy only from main - #40

Merged
explise merged 1 commit into
mainfrom
ci/docs-pr-gate
Jul 19, 2026
Merged

ci(docs): build the site on pull requests, deploy only from main#40
explise merged 1 commit into
mainfrom
ci/docs-pr-gate

Conversation

@explise

@explise explise commented Jul 19, 2026

Copy link
Copy Markdown
Owner

docs.yml had no pull_request trigger — only push-to-main and workflow_dispatch. So mkdocs build --strict never ran before merge.

The consequence: a broken in-site link passes review unnoticed, then fails after merge on the deploy — the point where a failure is most visible and least convenient, and where main is already carrying the bad link. --strict is only a gate if it runs before merge.

Changes

Adds the pull_request trigger with the same paths filter, and keeps PRs from publishing anything:

Change Why
deploy gated on github.event_name != 'pull_request' A PR proves the site builds; it must never touch the live site.
Pages artifact upload gated the same way It only feeds deploy, which never runs on a PR.
Pages write scopes moved from workflow → deploy job Previously every job got pages: write + id-token: write. A PR run now holds contents: read alone and cannot publish even in principle.
Concurrency split by event Deploys keep the shared pages group and still never cancel one in flight. PR builds get a per-ref group, so they neither queue behind a deploy nor hold one up, and a new push to a PR supersedes its own earlier build.

That last one matters: leaving PR builds in the shared pages group would have made every PR serialise against the deploy queue.

Verification

Ran the pinned toolchain locally (mkdocs==1.6.1 + mkdocs-material==9.7.6, matching the workflow):

  • mkdocs build --strictexit 0 on the current tree. This is preventive, not fixing a break already present.
  • Workflow YAML parsed to confirm the three triggers, both if gates, and the moved permissions block.

Self-demonstrating

This PR changes .github/workflows/docs.yml, which matches the new paths filter — so the workflow exercises itself here. Expected on this PR: docs / build runs and passes, docs / deploy is skipped. Worth confirming that in the checks before merging, since it's the whole point of the change.

docs.yml had no `pull_request` trigger — only push-to-main and
workflow_dispatch. So `mkdocs build --strict` never ran before merge, and a
broken in-site link passed review unnoticed and failed afterwards on the
deploy: the point where a failure is most visible and least convenient, and
where main is already carrying the bad link. `--strict` is only a gate if it
runs before merge.

Adds the pull_request trigger with the same paths filter, and keeps PRs from
publishing anything:

- `deploy` is gated on `github.event_name != 'pull_request'`, so a PR proves
  the site builds and never touches the live site.
- The Pages artifact upload is gated the same way; it only feeds `deploy`.
- Pages write scopes moved from the workflow down to the `deploy` job.
  Previously every job got `pages: write` and `id-token: write`; now a
  pull-request run holds `contents: read` alone and cannot publish even in
  principle.
- Concurrency is split by event. Deploys keep the shared `pages` group and
  still never cancel one in flight; PR builds get a per-ref group so they
  neither queue behind a deploy nor hold one up, and a new push to a PR
  supersedes that PR's earlier build.

Verified locally with the pinned toolchain (mkdocs 1.6.1 + mkdocs-material
9.7.6 in a venv): `mkdocs build --strict` exits 0 on the current tree, so
this is preventive rather than fixing a break already present. Workflow YAML
parsed to confirm the triggers, the two `if` gates, and the moved
permissions.

This PR changes .github/workflows/docs.yml, which matches the new filter, so
the workflow exercises itself here: docs should run and build, and deploy
should be skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@explise
explise merged commit d2ccbe8 into main Jul 19, 2026
2 checks passed
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