ci: deploy docs from a main ref via workflow_run on Release - #160
Merged
Conversation
`deploy-docs.yml` triggered on `release: published`, which runs against the release *tag*. The `github-pages` environment allows deployments only from `main` (custom branch policies, no tag policies), so the Deploy job was rejected before running a step -- this path never worked (beta.8 and beta.9 both failed). `origin/main` is at 5.0.0-beta.9 while the live /beta/ site still advertises beta.8, and at GA the root site would keep serving v4.3.0. Trigger on `workflow_run` of the Release workflow instead: a `workflow_run` event runs against the default branch, so the ref is `main` and the existing environment policy passes -- no new secret, no repository-settings change. The jobs are gated on a successful Release; `push` on `docs/**` and `workflow_dispatch` are unchanged. Release is itself `workflow_run`-triggered (on CI), so this is a chained `workflow_run`, which GitHub does not guarantee will fire. The comment block documents that risk, the manual-dispatch fallback, and the tag-policy fallback. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the documentation deployment workflow so that docs are deployed from main after the Release workflow completes, avoiding GitHub Pages environment protection failures that occur when deploying from a release tag ref.
Changes:
- Switches the docs deploy trigger from
release: publishedtoworkflow_runon theReleaseworkflow (branchmain). - Adds detailed rationale + fallback documentation in the workflow header.
- Gates the
buildjob soworkflow_run-triggered deploys only proceed after a successful Release conclusion.
Comments suppressed due to low confidence (1)
.github/workflows/deploy-docs.yml:69
- For
workflow_run, this workflow executes on the default branch and${{ github.sha }}can be the currentmainHEAD, not the triggering Release run’shead_sha. Ifmainadvances between the Release completion and this workflow starting, the deploy can build from the wrong commit/version. Pinactions/checkouttogithub.event.workflow_run.head_shaforworkflow_runevents.
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
`workflow_run` has no conclusion filter in `on:`, so a failed or cancelled Release still starts a Deploy Documentation run. Workflow-level concurrency is evaluated when the run is created — before any job-level `if:` — so that run joined the `pages` group and could cancel a real in-flight Pages deploy before skipping its own `build`, silently leaving the site stale. Make the group conditional: a run that cannot deploy gets a throwaway `pages-noop-<run_id>` group; every deploy-capable path (successful `workflow_run`, `push` on docs/**, `workflow_dispatch`) still resolves to `pages` and serialises exactly as before. The `build` job's `if:` is kept — it is what prevents the deploy; the group only governs contention. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The docs deploy has never worked on a release. Run
30370012795
is the latest instance; beta.8 failed identically:
deploy-docs.ymltriggers onrelease: published, so the run's ref is therelease tag. The
github-pagesenvironment uses custom branch policies witha single
mainpolicy and no tag policies, so the Deploy job is rejected beforerunning a single step. Push-to-
mainruns have always succeeded, which is whythis went unnoticed.
Why it matters more than a red tick
Release commits never touch
docs/**— I checked the last fivechore: release packagescommits: zerodocs/files each. So thepushtrigger's path filter never fires for a release, and the release trigger is the
only path that refreshes the site when a version ships.
The site is already stale in production:
mainis at5.0.0-beta.9, while/beta/still advertisesv5.0.0-beta.8.It gets worse at GA. The root site is built from the latest stable tag
(prereleases filtered out), so today it correctly serves v4.3.0. When 5.0.0
ships,
stable_tagbecomesunthrown@5.0.0and the root must rebuild from it —but the pre-exit/release commit won't touch
docs/**either. Without a workingpost-publish deploy, the root would keep serving v4.3.0 docs after 5.0.0 is
published, with no error anywhere.
The fix
Trigger on
workflow_runof the Release workflow instead.workflow_runevents run against the default branch, so the ref is
main, the existing policypasses, and no new secret or repository setting is needed.
Alternatives considered and rejected (all recorded in the workflow's comment
block, since that is where a future maintainer will look):
GITHUB_TOKEN— GitHub does not create new workflow runsfrom
GITHUB_TOKEN-triggered events, so it would be a silent no-op.RELEASE_PAT— documented upstream as Contents +Pull requests write only; no Actions write.
main— the "Version Packages"merge lands before publish, so the new tag does not exist yet. At GA this
would build the wrong version while appearing to succeed.
(
unthrown@*and@unthrown/*@*, since the publishing run's tag varies perrelease and
*does not match the/in a scoped tag). Kept as thedocumented fallback.
Also removes the seven-runs-racing burst: a monorepo release fired one run per
package Release and cancelled six of them.
workflow_runfires once.Known risk, documented in the file
Releaseis itselfworkflow_run-triggered, so this is a chain:CI → Release → Deploy Documentation. Chained
workflow_runtriggers are notguaranteed to fire, and this cannot be tested without a real release.
What to check on the next release: a Deploy Documentation run should appear
with event
workflow_runand refmain, the Deploy job should not be rejected,and
/beta/should advertise the newly published version. If no run appears,apply the fallback documented in the workflow header.
workflow_dispatchisretained and deploys from
mainmanually in the meantime.Checklist
CLAUDE.mdif the public surface or a design rule changed — n/a🤖 Generated with Claude Code