7
7
types : [opened, synchronize, reopened, closed]
8
8
9
9
env :
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 }}
10
16
PUBLISH_DIR : doc/_build/html/
11
17
12
18
defaults :
@@ -125,36 +131,40 @@ jobs:
125
131
working-directory : ' dpnp/backend/doc'
126
132
127
133
- name : Copy backend docs
128
- run : cp -r dpnp/backend/doc/html doc/_build/html /backend_doc
134
+ run : cp -r dpnp/backend/doc/html ${{ env.PUBLISH_DIR }} /backend_doc
129
135
130
136
# https://github.com/marketplace/actions/github-pages-action
137
+ # The step is only used to build docs while pushing a PR to "master"
131
138
- name : Deploy docs
132
- if : |
133
- github.event.pull_request && !github.event.pull_request.head.repo.fork &&
134
- (github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
139
+ if : env.GH_EVENT_PUSH_UPSTREAM
135
140
136
141
with :
137
142
github_token : ${{ secrets.GITHUB_TOKEN }}
138
143
publish_dir : ${{ env.PUBLISH_DIR }}
144
+ keep_files : true
145
+ commit_message : ${{ github.event.head_commit.message }}
146
+ publish_branch : gh-pages
147
+ user_name : ${{ env.GH_BOT_NAME }}
148
+ user_email : ${{ env.GH_BOT_EMAIL }}
139
149
150
+ # The step is only used to build docs while pushing to PR branch
140
151
- name : Publish pull-request docs
141
- if : |
142
- github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
152
+ if : env.GH_EVENT_OPEN_PR_UPSTREAM
143
153
144
154
with :
145
155
github_token : ${{ secrets.GITHUB_TOKEN }}
146
156
publish_dir : ${{ env.PUBLISH_DIR }}
147
157
destination_dir : ./pull/${{ github.event.number }}
148
158
allow_empty_commit : true
149
159
keep_files : true
150
- commit_message : ${{ github.event.head_commit.message }}
160
+ commit_message : ${{ github.event.pull_request.title }}
151
161
publish_branch : gh-pages
152
- user_name : ' github-actions[bot] '
153
- user_email : ' github-actions[bot]@users.noreply.github.com '
162
+ user_name : ${{ env.GH_BOT_NAME }}
163
+ user_email : ${{ env.GH_BOT_EMAIL }}
154
164
165
+ # The step is only used to build docs while pushing to PR branch
155
166
- name : Comment with URL to published pull-request docs
156
- if : |
157
- github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
167
+ if : env.GH_EVENT_OPEN_PR_UPSTREAM
158
168
env :
159
169
PR_NUM : ${{ github.event.number }}
160
170
@@ -163,9 +173,11 @@ jobs:
163
173
View rendered docs @ https://intelpython.github.io/dpnp/pull/${{ env.PR_NUM }}/index.html
164
174
allow-repeats : false
165
175
176
+ # The job is only used to build docs when PR is closed (action from PR branch)
166
177
clean :
167
178
if : |
168
- github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed'
179
+ github.event_name == 'pull_request' && github.event.action == 'closed' &&
180
+ github.event.pull_request && !github.event.pull_request.head.repo.fork
169
181
170
182
needs : build-and-deploy
171
183
@@ -185,8 +197,8 @@ jobs:
185
197
git checkout --track tokened_docs/gh-pages
186
198
echo `pwd`
187
199
[ -d pull/${PR_NUM} ] && git rm -rf pull/${PR_NUM}
188
- git config --global user.name 'github-actions[bot]'
189
- git config --global user.email 'github-actions[bot]@users.noreply.github.com'
200
+ git config --global user.name ${{ env.GH_BOT_NAME }}
201
+ git config --global user.email ${{ env.GH_BOT_EMAIL }}
190
202
git commit -m "Removing docs for closed pull request ${PR_NUM}"
191
203
git push tokened_docs gh-pages
192
204
0 commit comments