Skip to content

Commit addad90

Browse files
committed
Added global env variables for GitHub events
1 parent de285bf commit addad90

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

.github/workflows/build-sphinx.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ on:
77
types: [opened, synchronize, reopened, closed]
88

99
env:
10-
GITHUB_BOT_NAME: 'github-actions[bot]'
11-
GITHUB_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
10+
GH_BOT_NAME: 'github-actions[bot]'
11+
GH_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
12+
GH_EVENT_OPEN_PR_UPSTREAM: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' &&
13+
github.event.pull_request && !github.event.pull_request.head.repo.fork }}
14+
GH_EVENT_PUSH_UPSTREAM: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' &&
15+
github.event.ref == 'refs/heads/master' && github.event.repository && !github.event.repository.fork }}
1216
PUBLISH_DIR: doc/_build/html/
1317

1418
defaults:
@@ -130,26 +134,22 @@ jobs:
130134
run: cp -r dpnp/backend/doc/html ${{ env.PUBLISH_DIR }}/backend_doc
131135

132136
# https://github.com/marketplace/actions/github-pages-action
133-
# The step is only used to build docs while pushing PR to "master"
137+
# The step is only used to build docs while pushing a PR to "master"
134138
- name: Deploy docs
135-
if: |
136-
github.ref == 'refs/heads/master' && github.event_name == 'push' &&
137-
github.event.ref == 'refs/heads/master' && github.event.repository && !github.event.repository.fork
139+
if: env.GH_EVENT_PUSH_UPSTREAM
138140
uses: peaceiris/[email protected]
139141
with:
140142
github_token: ${{ secrets.GITHUB_TOKEN }}
141143
publish_dir: ${{ env.PUBLISH_DIR }}
142144
keep_files: true
143145
commit_message: ${{ github.event.head_commit.message }}
144146
publish_branch: gh-pages
145-
user_name: ${{ env.GITHUB_BOT_NAME }}
146-
user_email: ${{ env.GITHUB_BOT_EMAIL }}
147+
user_name: ${{ env.GH_BOT_NAME }}
148+
user_email: ${{ env.GH_BOT_EMAIL }}
147149

148150
# The step is only used to build docs while pushing to PR branch
149151
- name: Publish pull-request docs
150-
if: |
151-
github.event_name == 'pull_request' && github.event.action != 'closed' &&
152-
github.event.pull_request && !github.event.pull_request.head.repo.fork
152+
if: env.GH_EVENT_OPEN_PR_UPSTREAM
153153
uses: peaceiris/[email protected]
154154
with:
155155
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -159,14 +159,12 @@ jobs:
159159
keep_files: true
160160
commit_message: ${{ github.event.pull_request.title }}
161161
publish_branch: gh-pages
162-
user_name: ${{ env.GITHUB_BOT_NAME }}
163-
user_email: ${{ env.GITHUB_BOT_EMAIL }}
162+
user_name: ${{ env.GH_BOT_NAME }}
163+
user_email: ${{ env.GH_BOT_EMAIL }}
164164

165165
# The step is only used to build docs while pushing to PR branch
166166
- name: Comment with URL to published pull-request docs
167-
if: |
168-
github.event_name == 'pull_request' && github.event.action != 'closed' &&
169-
github.event.pull_request && !github.event.pull_request.head.repo.fork
167+
if: env.GH_EVENT_OPEN_PR_UPSTREAM
170168
env:
171169
PR_NUM: ${{ github.event.number }}
172170
uses: mshick/[email protected]
@@ -199,8 +197,8 @@ jobs:
199197
git checkout --track tokened_docs/gh-pages
200198
echo `pwd`
201199
[ -d pull/${PR_NUM} ] && git rm -rf pull/${PR_NUM}
202-
git config --global user.name ${{ env.GITHUB_BOT_NAME }}
203-
git config --global user.email ${{ env.GITHUB_BOT_EMAIL }}
200+
git config --global user.name ${{ env.GH_BOT_NAME }}
201+
git config --global user.email ${{ env.GH_BOT_EMAIL }}
204202
git commit -m "Removing docs for closed pull request ${PR_NUM}"
205203
git push tokened_docs gh-pages
206204

0 commit comments

Comments
 (0)