|
4 | 4 | branches:
|
5 | 5 | - master
|
6 | 6 | pull_request:
|
| 7 | + types: [opened, synchronize, reopened, closed] |
| 8 | + |
| 9 | +env: |
| 10 | + PUBLISH_DIR: doc/_build/html/ |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash -l {0} |
7 | 15 |
|
8 | 16 | jobs:
|
9 | 17 | build-and-deploy:
|
10 | 18 | name: Build and Deploy Docs
|
11 | 19 |
|
12 | 20 | runs-on: ubuntu-20.04
|
13 | 21 |
|
14 |
| - defaults: |
15 |
| - run: |
16 |
| - shell: bash -l {0} |
17 |
| - |
18 | 22 | env:
|
19 | 23 | python-ver: '3.9'
|
20 | 24 | CHANNELS: '-c dppy/label/dev -c intel -c conda-forge --override-channels'
|
@@ -116,4 +120,64 @@ jobs:
|
116 | 120 |
|
117 | 121 | with:
|
118 | 122 | github_token: ${{ secrets.GITHUB_TOKEN }}
|
119 |
| - publish_dir: doc/_build/html/ |
| 123 | + publish_dir: ${{ env.PUBLISH_DIR }} |
| 124 | + |
| 125 | + - name: Publish pull-request docs |
| 126 | + if: | |
| 127 | + !github.event.pull_request.head.repo.fork && github.event.pull_request && github.event.action != 'closed' |
| 128 | + |
| 129 | + with: |
| 130 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + publish_dir: ${{ env.PUBLISH_DIR }} |
| 132 | + destination_dir: ./pull/${{ github.event.number }} |
| 133 | + allow_empty_commit : true |
| 134 | + commit_message: ${{ github.event.head_commit.message }} |
| 135 | + publish_branch: gh-pages |
| 136 | + user_name: 'github-actions[bot]' |
| 137 | + user_email: 'github-actions[bot]@users.noreply.github.com' |
| 138 | + |
| 139 | + - name: Comment with URL to published pull-request docs |
| 140 | + if: | |
| 141 | + !github.event.pull_request.head.repo.fork && github.event.pull_request && github.event.action != 'closed' |
| 142 | + env: |
| 143 | + PR_NUM: ${{ github.event.number }} |
| 144 | + |
| 145 | + with: |
| 146 | + message: | |
| 147 | + View rendered docs @ https://intelpython.github.io/dpnp/pulls/${{ env.PR_NUM }}/index.html |
| 148 | + allow-repeats: false |
| 149 | + |
| 150 | + clean: |
| 151 | + if: | |
| 152 | + !github.event.pull_request.head.repo.fork && github.event.pull_request && github.event.action == 'closed' |
| 153 | +
|
| 154 | + needs: build-and-deploy |
| 155 | + |
| 156 | + runs-on: ubuntu-20.04 |
| 157 | + |
| 158 | + steps: |
| 159 | + |
| 160 | + with: |
| 161 | + fetch-depth: 0 |
| 162 | + |
| 163 | + - name: Remove docs [PR closed] |
| 164 | + env: |
| 165 | + PR_NUM: ${{ github.event.number }} |
| 166 | + run: | |
| 167 | + git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpnp.git |
| 168 | + git fetch tokened_docs |
| 169 | + git checkout --track tokened_docs/gh-pages |
| 170 | + echo `pwd` |
| 171 | + [ -d pull/${PR_NUM} ] && git rm -rf pull/${PR_NUM} |
| 172 | + git config --global user.name 'github-actions[bot]' |
| 173 | + git config --global user.email 'github-actions[bot]@users.noreply.github.com' |
| 174 | + git commit -m "Removing docs for closed pull request ${PR_NUM}" |
| 175 | + git push tokened_docs gh-pages |
| 176 | +
|
| 177 | + - name: Modify the comment with URL to official documentation |
| 178 | + |
| 179 | + with: |
| 180 | + find: | |
| 181 | + View rendered docs @.+ |
| 182 | + replace: | |
| 183 | + View rendered docs @ https://intelpython.github.io/dpnp/index.html |
0 commit comments