Skip to content

Build the site on pull requests, publish only from main - #24

Merged
tannevaled merged 1 commit into
mainfrom
pages-pr-build
Aug 30, 2026
Merged

Build the site on pull requests, publish only from main#24
tannevaled merged 1 commit into
mainfrom
pages-pr-build

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

[2026-08-30 17:51:18 CEST]

The blind spot

The Pages workflow in this repository triggered on push to main and
workflow_dispatch only. Nothing ran on a pull request, so
GET /repos/<owner>/<repo>/commits/<head sha>/check-runs returned
total_count: 0 for any pull request opened here. A dependency bump or a
content change was mergeable with nothing verifying it, and the first evidence
of a mistake would have been a broken published site. "No checks" is not the
same thing as green.

The fix

  • pull_request is added to the triggers, so the build proves the site still
    builds before a change lands.
  • The deploy job is gated on github.event_name != 'pull_request'. A pull
    request stops after the build; it never publishes.
  • pages: write and id-token: write move down to the deploy job, the only
    job that needs them, so a pull request build cannot publish even if a step in
    it misbehaves.
  • The concurrency group is scoped by ref, so a pull request neither waits
    behind a deploy nor holds one up.

How this was found, and how far it goes

Every public repository in all 320 organisations was swept: 1820 public repos,
1453 workflow files read, 573 of them publish to GitHub Pages. 565 already
carry a pull_request trigger with a gated deploy job; this repository was one
of only 8 that did not. The pattern applied here is the one the other 565
already use.

Verified first on go-pdfkit/go-pdfkit.github.io#8, where the head sha went from
total_count: 0 to two check runs: build success, deploy skipped.

The Pages workflow triggered on `push` to main and `workflow_dispatch` only,
so nothing ran on a pull request: a dependency bump or a content change was
mergeable with `total_count: 0` check runs on its head sha, and the first
evidence of a mistake would have been a broken published site. "No checks" is
not the same thing as green.

Add a `pull_request` trigger so the build proves the site still builds, and
gate the deploy job on the event so a pull request never publishes.

Permissions and concurrency follow from that: `pages: write` and
`id-token: write` move down to the deploy job, the only job that needs them,
and the concurrency group is scoped by ref so a pull request neither waits
behind a deploy nor holds one up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit c4f12d3 into main Aug 30, 2026
3 checks passed
@tannevaled
tannevaled deleted the pages-pr-build branch August 30, 2026 16:04
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