Skip to content

Commit 63b2ded

Browse files
antonwolfyclaude
andcommitted
Add GH_EVENT_PR_OPEN environment variable for cleaner conditions
Replaced repeated condition `github.event_name == 'pull_request' && github.event.action != 'closed'` with a single environment variable `GH_EVENT_PR_OPEN` for better readability and maintainability. Updated 3 steps to use the new variable: - Upload docs artifact (Fork PRs) - Publish pull-request docs - Comment with URL to published pull-request docs Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 56fe652 commit 63b2ded

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

.github/workflows/build-sphinx.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ env:
1313
GH_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
1414
GH_EVENT_PUSH_UPSTREAM: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' &&
1515
github.event.ref == 'refs/heads/master' && github.event.repository && !github.event.repository.fork }}
16+
GH_EVENT_PR_OPEN: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' }}
1617
PUBLISH_DIR: doc/_build/html/
1718

1819
defaults:
@@ -202,7 +203,7 @@ jobs:
202203
203204
# Upload artifact for fork PRs
204205
- name: Upload docs artifact (Fork PRs)
205-
if: steps.check_fork.outputs.is_fork == 'true' && github.event.action != 'closed'
206+
if: env.GH_EVENT_PR_OPEN == 'true' && steps.check_fork.outputs.is_fork == 'true'
206207
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
207208
with:
208209
name: pr-${{ github.event.number }}-docs
@@ -224,7 +225,7 @@ jobs:
224225

225226
# The step is only used to build docs while pushing to PR branch
226227
- name: Publish pull-request docs
227-
if: github.event_name == 'pull_request' && github.event.action != 'closed' && steps.check_fork.outputs.is_fork == 'false'
228+
if: env.GH_EVENT_PR_OPEN == 'true' && steps.check_fork.outputs.is_fork == 'false'
228229
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
229230
with:
230231
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -241,7 +242,7 @@ jobs:
241242
# Note: Fork PRs have read-only GITHUB_TOKEN and cannot post comments
242243
# See: https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflows-in-forked-repositories
243244
- name: Comment with URL to published pull-request docs
244-
if: github.event_name == 'pull_request' && github.event.action != 'closed' && steps.check_fork.outputs.is_fork == 'false'
245+
if: env.GH_EVENT_PR_OPEN == 'true' && steps.check_fork.outputs.is_fork == 'false'
245246
env:
246247
PR_NUM: ${{ github.event.number }}
247248
uses: mshick/add-pr-comment@8e4927817251f1ff60c001f04568532b38e0b4a0 # v3.11.0.8.3.11.0

0 commit comments

Comments
 (0)