Skip to content

Commit ce76960

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

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

.github/workflows/generate-docs.yml

Lines changed: 39 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,44 +16,54 @@ 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
4653
- name: Checkout repo
54+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
4755
uses: actions/checkout@v2
4856
with:
4957
fetch-depth: 0
5058
- name: Build dpctl
59+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
5160
shell: bash -l {0}
5261
run: |
5362
source /opt/intel/oneapi/setvars.sh
5463
python setup.py develop
5564
python -c "import dpctl; print(dpctl.__version__)"
5665
- name: Build docs
66+
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
5767
shell: bash -l {0}
5868
run: |
5969
# Ensure that SYCL libraries are on LD_LIBRARY_PATH
@@ -87,7 +97,7 @@ jobs:
8797
git commit -m "Latest docs."
8898
git push tokened_docs gh-pages
8999
- name: Publish pull-request docs
90-
if: ${{ github.ref != 'refs/heads/master' }}
100+
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
91101
env:
92102
PR_NUM: ${{ github.event.number }}
93103
shell: bash -l {0}
@@ -105,8 +115,23 @@ jobs:
105115
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
106116
git commit -m "Docs for pull request ${PR_NUM}"
107117
git push tokened_docs gh-pages
108-
- name: Comment with URL to pull-request docs
109-
if: ${{ github.ref != 'refs/heads/master' }}
118+
- name: Unpublished pull-request docs
119+
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
120+
env:
121+
PR_NUM: ${{ github.event.number }}
122+
shell: bash -l {0}
123+
run: |
124+
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
125+
git fetch tokened_docs
126+
git checkout --track tokened_docs/gh-pages
127+
echo `pwd`
128+
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM}
129+
git config --global user.name 'github-actions[doc-deploy-bot]'
130+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
131+
git commit -m "Removing docs for closed pull request ${PR_NUM}"
132+
git push tokened_docs gh-pages
133+
- name: Comment with URL to published pull-request docs
134+
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
110135
env:
111136
PR_NUM: ${{ github.event.number }}
112137
uses: mshick/add-pr-comment@v1
@@ -115,3 +140,13 @@ jobs:
115140
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${{ env.PR_NUM }}/index.html
116141
repo-token: ${{ secrets.GITHUB_TOKEN }}
117142
repo-token-user-login: 'github-actions[bot]'
143+
- name: Comment with URL about removal of PR docs
144+
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
145+
env:
146+
PR_NUM: ${{ github.event.number }}
147+
uses: mshick/add-pr-comment@v1
148+
with:
149+
message: |
150+
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. :crossed_fingers:
151+
repo-token: ${{ secrets.GITHUB_TOKEN }}
152+
repo-token-user-login: 'github-actions[bot]'

0 commit comments

Comments
 (0)