fix: skip docs build/publish on pull_request, not just push - #222
Open
petercorke wants to merge 1 commit into
Open
petercorke wants to merge 1 commit into
petercorke wants to merge 1 commit into
Conversation
The sphinx job unconditionally ran (and tried to publish to gh-pages) on every PR, including ones whose branch lives in a fork -- even the author's own fork (e.g. #198). GitHub Actions always issues a read-only GITHUB_TOKEN for pull_request-triggered runs when the head repo differs from the base repo, so the gh-pages push step there fails by design, regardless of repo/workflow permission settings. There was already a commented-out attempt at this exact guard inside sphinx.yml itself (`if: github.event_name != 'pull_request'`), but it could never have worked there: sphinx.yml is invoked via `workflow_call`, and github.event_name inside a called workflow is always "workflow_call", never the original triggering event. Moving the condition to the caller job in master.yml (which does see the real triggering event) is what actually works -- removed the dead comment from sphinx.yml accordingly. This also means PR runs no longer spend ~10+ minutes building docs that were never going anywhere, and unreviewed PR content never reaches the live public docs site.
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 `sphinx` job in `master.yml` runs unconditionally on every trigger -- `push` (merge to master/future) and `pull_request`. On a PR whose branch lives in a fork -- including the author's own fork (this is what happened on #198) -- the job's final "push to gh-pages" step always fails:
```
remote: Permission to rai-opensource/spatialmath-python.git denied to github-actions[bot].
fatal: unable to access '...': The requested URL returned error: 403
```
This is GitHub Actions' own security policy: `GITHUB_TOKEN` is hardcoded read-only for `pull_request`-triggered runs whenever the head repo differs from the base repo, regardless of any repo/workflow permission settings. Not a bug in this repo, not fixable by changing settings -- the fix is to simply not attempt the gh-pages publish during PR runs at all, which is also the right behaviour independent of the permission issue (unreviewed PR content shouldn't land on the live public docs site).
What's changed
Side benefit
PR runs no longer spend ~10+ minutes building docs that were never going to be published anyway.
Test plan