Skip to content

Commit c58f65f

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

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

.github/workflows/generate-docs.yml

Lines changed: 33 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:
@@ -69,6 +71,7 @@ jobs:
6971
git clean -dfx
7072
cd ..
7173
- name: Publish docs
74+
if: ${{ github.ref == 'refs/heads/master' }}
7275
shell: bash -l {0}
7376
run: |
7477
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
@@ -80,6 +83,35 @@ jobs:
8083
mv ~/docs/* .
8184
git add .
8285
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'
86+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
8487
git commit -m "Latest docs."
8588
git push tokened_docs gh-pages
89+
- name: Publish pull-request docs
90+
if: ${{ github.ref != 'refs/heads/master' }}
91+
env:
92+
PR_NUM: ${{ github.event.number }}
93+
shell: bash -l {0}
94+
run: |
95+
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
96+
git fetch tokened_docs
97+
git checkout --track tokened_docs/gh-pages
98+
echo `pwd`
99+
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM}
100+
mkdir -p pulls/${PR_NUM}
101+
cd pulls/${PR_NUM}
102+
mv ~/docs/* .
103+
git add .
104+
git config --global user.name 'github-actions[doc-deploy-bot]'
105+
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
106+
git commit -m "Docs for pull request ${PR_NUM}"
107+
git push tokened_docs gh-pages
108+
- name: Comment with URL to pull-request docs
109+
if: ${{ github.ref != 'refs/heads/master' }}
110+
env:
111+
PR_NUM: ${{ github.event.number }}
112+
uses: mshick/add-pr-comment@v1
113+
with:
114+
message: |
115+
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${PR_NUM}/index.html
116+
repo-token: ${{ secrets.GITHUB_TOKEN }}
117+
repo-token-user-login: 'github-actions[bot]'

0 commit comments

Comments
 (0)