Skip to content

Commit f890d9b

Browse files
Try to publish generated_docs from PR sources and comment on the PR
1 parent 9d264fd commit f890d9b

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

.github/workflows/generate-docs.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
push:
44
branches:
55
- master
6+
pull_request:
7+
68

79
jobs:
810
build-and-deploy:
@@ -66,9 +68,12 @@ jobs:
6668
make Sphinx
6769
cd ..
6870
mv generated_docs/docs ~/docs
71+
ls -l ~/docs
6972
git clean -dfx
73+
ls -l ~/docs
7074
cd ..
7175
- name: Publish docs
76+
if: ${{ github.ref == 'refs/heads/master' }}
7277
shell: bash -l {0}
7378
run: |
7479
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
@@ -80,6 +85,36 @@ jobs:
8085
mv ~/docs/* .
8186
git add .
8287
git config --global user.name 'github-actions[doc-deploy-bot]'
83-
git config --gloabl user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
88+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
8489
git commit -m "Latest docs."
8590
git push tokened_docs gh-pages
91+
- name: Publish pull-request docs
92+
if: ${{ github.ref != 'refs/heads/master' }}
93+
env:
94+
PR_NUM: ${{ github.event.number }}
95+
shell: bash -l {0}
96+
run: |
97+
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
98+
git fetch tokened_docs
99+
git checkout --track tokened_docs/gh-pages
100+
echo `pwd`
101+
mkdir -p pulls/${PR_NUM}
102+
cd pulls/${PR_NUM}
103+
git rm -rf *
104+
ls -l ~
105+
mv ~/docs/* .
106+
git add .
107+
git config --global user.name 'github-actions[doc-deploy-bot]'
108+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
109+
git commit -m "Docs for pull request ${PR_NUM}"
110+
git push tokened_docs gh-pages
111+
- name: Comment with URL to pull-request docs
112+
if: ${{ github.ref != 'refs/heads/master' }}
113+
env:
114+
PR_NUM: ${{ github.event.number }}
115+
uses: mshick/add-pr-comment@v1
116+
with:
117+
message: |
118+
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${PR_NUM}/index.html
119+
repo-token: ${{ secrets.GITHUB_TOKEN }}
120+
repo-token-user-login: 'github-actions[bot]'

0 commit comments

Comments
 (0)