Skip to content

ci: validate pull requests before they merge - #16

Merged
krassx merged 1 commit into
mainfrom
ci/validate-pull-requests
Aug 10, 2026
Merged

ci: validate pull requests before they merge#16
krassx merged 1 commit into
mainfrom
ci/validate-pull-requests

Conversation

@krassx

@krassx krassx commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

The workflow only triggered on pushes to main, so content PRs could not be validated until after they merged.

That's not hypothetical — #13 merged clean and immediately turned main red, because three spelling issues had no opportunity to surface earlier. #15's description had to carry a "merge #14 first" note for the same reason.

What changes

Pull requests now run the same checkout / install / spell-check / build steps a deploy runs, and stop before touching AWS.

Reusing the single existing job — rather than adding a separate validation workflow — means a PR necessarily runs exactly what the deploy will run. A second workflow would be free to drift from it.

The three AWS steps are guarded with github.event_name != 'pull_request', so a PR run performs no OIDC exchange, no S3 sync, and no CloudFront invalidation.

Two deliberate choices

No paths-ignore on the PR trigger, unlike push. Skipping a deploy for a change that can't affect the built site is worthwhile; skipping validation isn't. A workflow or config change is precisely what's worth checking on the PR, and the run is cheap.

Concurrency is unaffected. github.ref is refs/pull/<n>/merge on a PR, so validation runs get their own group and can't cancel an in-flight deploy of main.

One thing worth your call

id-token: write stays declared at workflow level and is simply unused on PR runs, since every AWS step is skipped. Scoping it to a deploy-only job would require either a second build or passing the build output between jobs as an artifact. Happy to do that if the broader permission on PR runs bothers you — I kept the diff minimal instead.

Verified

YAML parses, and the trigger/guard structure is as intended:

triggers: [ 'pull_request', 'push', 'workflow_dispatch' ]
  Checkout                          if=—
  Setup Node.js                     if=—
  Install dependencies              if=—
  Spell check                       if=—
  Build site                        if=—
  Configure AWS credentials (OIDC)  if=github.event_name != 'pull_request'
  Sync to S3                        if=github.event_name != 'pull_request'
  Invalidate CloudFront             if=github.event_name != 'pull_request'

This PR should be its own proof: once open, it ought to run the validation job and stop short of deploying.

🤖 Generated with Claude Code

The workflow only triggered on pushes to main, so a content PR could not be
checked until AFTER it merged. That is not hypothetical: #13 merged clean
and immediately turned main red, because three spelling issues had no
opportunity to surface earlier.

Pull requests now run the same checkout / install / spell-check / build
steps a deploy runs, and stop before touching AWS. Reusing the one job
rather than adding a separate validation workflow means the PR necessarily
runs what the deploy will run — a second workflow could drift from it.

The three AWS steps are guarded with `github.event_name != 'pull_request'`,
so a PR run performs no OIDC exchange, no S3 sync and no CloudFront
invalidation.

No paths-ignore on the PR trigger, unlike push: skipping a deploy for a
change that cannot affect the built site is worthwhile, but skipping
VALIDATION is not — a workflow or config change is exactly the kind of
thing worth checking on the PR, and the run is cheap.

Concurrency is unaffected: github.ref is refs/pull/<n>/merge on a PR, so
validation runs get their own group and cannot cancel a deploy of main.

Note the id-token: write permission stays declared at workflow level and is
simply unused on PR runs. Scoping it to a deploy-only job would need either
a second build or artifact passing between jobs; happy to do that if the
broader permission on PR runs is a concern.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Change-Id: I5cdc568b682e61723dfe0c2ca2142b660cd1b153
@krassx
krassx merged commit b31e21b into main Aug 10, 2026
1 check passed
@krassx
krassx deleted the ci/validate-pull-requests branch August 10, 2026 15:55
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