Skip to content

Commit 8c04681

Browse files
committed
fix: skip docs build/publish on pull_request, not just push
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.
1 parent f6a572c commit 8c04681

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎.github/workflows/master.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ jobs:
7777
file: ./coverage.xml
7878
sphinx:
7979
# If the above worked:
80-
# Build docs and upload to GH Pages
80+
# Build docs and upload to GH Pages -- only on push (merge to master/future),
81+
# never on pull_request: a PR whose branch lives in a fork (including the
82+
# author's own fork) gets a read-only GITHUB_TOKEN by GitHub's own design,
83+
# so the gh-pages push step always fails there regardless of repo settings.
84+
# Publishing unreviewed PR content to the live docs site isn't desired
85+
# either way.
8186
needs: unittest
87+
if: ${{ github.event_name != 'pull_request' }}
8288
uses: ./.github/workflows/sphinx.yml

‎.github/workflows/sphinx.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
jobs:
77
sphinx:
88
runs-on: ubuntu-22.04
9-
# if: ${{ github.event_name != 'pull_request' }}
109
steps:
1110
- uses: actions/checkout@v4
1211
- name: Set up Python 3.12

0 commit comments

Comments
 (0)