ci: skip docs preview deploy for PRs from forks#791
Open
andreahlert wants to merge 1 commit into
Open
Conversation
Forks cannot push to gh-pages because PR-from-fork GITHUB_TOKEN is read-only regardless of declared workflow permissions, causing the docs job to fail with "Resource not accessible by integration" on every fork PR. Gate the three steps that need write access (Comment on PR, Build PR preview website, Update comment) on PRs originating from this repository so the docs job still validates the Sphinx build for fork PRs without attempting the preview deploy.
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.
Summary
The
docsjob in.github/workflows/docs.ymlfails on every PR opened from a fork with the annotation:Root cause: for PRs from forks, GitHub provides a read-only
GITHUB_TOKENregardless of thepermissions:block declared in the workflow. Thepeaceiris/actions-gh-pagesstep that publishes the preview to thegh-pagesbranch therefore fails, and the comment-progress steps also fail to write PR comments.This blocks merging contributor PRs (e.g. #623) because
docsis a required status check — the only path forward today is admin override.Changes
Gate the three steps that need write access on PRs from the upstream repo only:
Comment on PRBuild PR preview websiteUpdate commentNew
ifcondition:Behaviour after change
main: unchanged — onlyDeploy to GitHub Pagesruns.apache/burr: unchanged — preview is built and deployed, comments posted.Sphinx buildstill validates docs; the three deploy/comment steps are skipped; job ends successfully.How I tested this
peaceiris/actions-gh-pagesstep at line 67).gh apithat recent docs runs on fork PRs arestartup_failure/failurewhile runs onmainsucceed.if:expression: for push tomain,github.event_name == 'pull_request'evaluates false, leaving the existingDeploy to GitHub Pagesstep (gated on push to main) as the only active deploy step.Notes
This only restores the previous level of preview coverage for in-repo PRs; it does not attempt to enable previews for forks (that would require
pull_request_targetand a careful audit of the checkout/build steps to avoid running untrusted PR code with elevated permissions).Checklist