Skip to content

Commit 9b7dfff

Browse files
Added logic for tearing down pulls/prNum after PR is closed
1 parent ec700a2 commit 9b7dfff

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

.github/workflows/generate-docs.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- master
66
pull_request:
7-
7+
types: [opened, synchronize, reopened, closed]
88

99
jobs:
1010
build-and-deploy:
@@ -16,30 +16,37 @@ jobs:
1616
with:
1717
access_token: ${{ github.token }}
1818
- name: Add Intel repository
19+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
1920
run: |
2021
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
2122
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
2223
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
2324
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
2425
sudo apt-get update
2526
- name: Install Intel OneAPI
27+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
2628
run: |
2729
sudo apt-get install intel-oneapi-dpcpp-cpp-compiler
2830
- name: Install Lua
31+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
2932
run: |
3033
sudo apt-get install liblua5.2-dev
3134
- name: Install Doxygen
35+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
3236
run: |
3337
sudo apt-get install doxygen
3438
- name: Install CMake
39+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
3540
run: |
3641
sudo apt-get install cmake
3742
- name: Setup Python
43+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
3844
uses: actions/setup-python@v2
3945
with:
4046
python-version: '3.8'
4147
architecture: x64
4248
- name: Install sphinx dependencies
49+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
4350
shell: bash -l {0}
4451
run: |
4552
pip install numpy cython setuptools sphinx sphinx_rtd_theme pydot graphviz
@@ -48,12 +55,14 @@ jobs:
4855
with:
4956
fetch-depth: 0
5057
- name: Build dpctl
58+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
5159
shell: bash -l {0}
5260
run: |
5361
source /opt/intel/oneapi/setvars.sh
5462
python setup.py develop
5563
python -c "import dpctl; print(dpctl.__version__)"
5664
- name: Build docs
65+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
5766
shell: bash -l {0}
5867
run: |
5968
# Ensure that SYCL libraries are on LD_LIBRARY_PATH
@@ -87,7 +96,7 @@ jobs:
8796
git commit -m "Latest docs."
8897
git push tokened_docs gh-pages
8998
- name: Publish pull-request docs
90-
if: ${{ github.ref != 'refs/heads/master' }}
99+
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
91100
env:
92101
PR_NUM: ${{ github.event.number }}
93102
shell: bash -l {0}
@@ -105,8 +114,23 @@ jobs:
105114
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
106115
git commit -m "Docs for pull request ${PR_NUM}"
107116
git push tokened_docs gh-pages
108-
- name: Comment with URL to pull-request docs
109-
if: ${{ github.ref != 'refs/heads/master' }}
117+
- name: Unpublished pull-request docs
118+
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
119+
env:
120+
PR_NUM: ${{ github.event.number }}
121+
shell: bash -l {0}
122+
run: |
123+
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
124+
git fetch tokened_docs
125+
git checkout --track tokened_docs/gh-pages
126+
echo `pwd`
127+
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM}
128+
git config --global user.name 'github-actions[doc-deploy-bot]'
129+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
130+
git commit -m "Removing docs for closed pull request ${PR_NUM}"
131+
git push tokened_docs gh-pages
132+
- name: Comment with URL to published pull-request docs
133+
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
110134
env:
111135
PR_NUM: ${{ github.event.number }}
112136
uses: mshick/add-pr-comment@v1
@@ -115,3 +139,13 @@ jobs:
115139
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${{ env.PR_NUM }}/index.html
116140
repo-token: ${{ secrets.GITHUB_TOKEN }}
117141
repo-token-user-login: 'github-actions[bot]'
142+
- name: Comment with URL about removal of PR docs
143+
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
144+
env:
145+
PR_NUM: ${{ github.event.number }}
146+
uses: mshick/add-pr-comment@v1
147+
with:
148+
message: |
149+
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. :crossed_fingers:
150+
repo-token: ${{ secrets.GITHUB_TOKEN }}
151+
repo-token-user-login: 'github-actions[bot]'

0 commit comments

Comments
 (0)