Skip to content

Commit de285bf

Browse files
committed
Update deploy step of a job with building docs
1 parent 780d686 commit de285bf

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

.github/workflows/build-sphinx.yml

+25-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ 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'
1012
PUBLISH_DIR: doc/_build/html/
1113

1214
defaults:
@@ -125,36 +127,46 @@ jobs:
125127
working-directory: 'dpnp/backend/doc'
126128

127129
- name: Copy backend docs
128-
run: cp -r dpnp/backend/doc/html doc/_build/html/backend_doc
130+
run: cp -r dpnp/backend/doc/html ${{ env.PUBLISH_DIR }}/backend_doc
129131

130132
# https://github.com/marketplace/actions/github-pages-action
133+
# The step is only used to build docs while pushing PR to "master"
131134
- name: Deploy docs
132135
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/'))
136+
github.ref == 'refs/heads/master' && github.event_name == 'push' &&
137+
github.event.ref == 'refs/heads/master' && github.event.repository && !github.event.repository.fork
135138
uses: peaceiris/[email protected]
136139
with:
137140
github_token: ${{ secrets.GITHUB_TOKEN }}
138141
publish_dir: ${{ env.PUBLISH_DIR }}
142+
keep_files: true
143+
commit_message: ${{ github.event.head_commit.message }}
144+
publish_branch: gh-pages
145+
user_name: ${{ env.GITHUB_BOT_NAME }}
146+
user_email: ${{ env.GITHUB_BOT_EMAIL }}
139147

148+
# The step is only used to build docs while pushing to PR branch
140149
- name: Publish pull-request docs
141150
if: |
142-
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
151+
github.event_name == 'pull_request' && github.event.action != 'closed' &&
152+
github.event.pull_request && !github.event.pull_request.head.repo.fork
143153
uses: peaceiris/[email protected]
144154
with:
145155
github_token: ${{ secrets.GITHUB_TOKEN }}
146156
publish_dir: ${{ env.PUBLISH_DIR }}
147157
destination_dir: ./pull/${{ github.event.number }}
148158
allow_empty_commit : true
149159
keep_files: true
150-
commit_message: ${{ github.event.head_commit.message }}
160+
commit_message: ${{ github.event.pull_request.title }}
151161
publish_branch: gh-pages
152-
user_name: 'github-actions[bot]'
153-
user_email: 'github-actions[bot]@users.noreply.github.com'
162+
user_name: ${{ env.GITHUB_BOT_NAME }}
163+
user_email: ${{ env.GITHUB_BOT_EMAIL }}
154164

165+
# The step is only used to build docs while pushing to PR branch
155166
- name: Comment with URL to published pull-request docs
156167
if: |
157-
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
168+
github.event_name == 'pull_request' && github.event.action != 'closed' &&
169+
github.event.pull_request && !github.event.pull_request.head.repo.fork
158170
env:
159171
PR_NUM: ${{ github.event.number }}
160172
uses: mshick/[email protected]
@@ -163,9 +175,11 @@ jobs:
163175
View rendered docs @ https://intelpython.github.io/dpnp/pull/${{ env.PR_NUM }}/index.html
164176
allow-repeats: false
165177

178+
# The job is only used to build docs when PR is closed (action from PR branch)
166179
clean:
167180
if: |
168-
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed'
181+
github.event_name == 'pull_request' && github.event.action == 'closed' &&
182+
github.event.pull_request && !github.event.pull_request.head.repo.fork
169183
170184
needs: build-and-deploy
171185

@@ -185,8 +199,8 @@ jobs:
185199
git checkout --track tokened_docs/gh-pages
186200
echo `pwd`
187201
[ -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'
202+
git config --global user.name ${{ env.GITHUB_BOT_NAME }}
203+
git config --global user.email ${{ env.GITHUB_BOT_EMAIL }}
190204
git commit -m "Removing docs for closed pull request ${PR_NUM}"
191205
git push tokened_docs gh-pages
192206

0 commit comments

Comments
 (0)