Skip to content

Commit 904de60

Browse files
Generate docs made friendly for PRs from forks
Only publish sources and comments with link to them for PRs opened from branches in this repo. PRs from forks would have artifacts with rendered docs uploaded.
1 parent 8a9ebe6 commit 904de60

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

.github/workflows/generate-docs.yml

+12-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
mv ../cmake-install/docs/docs ~/docs
7777
git clean -dfx
7878
- name: Publish docs
79-
if: ${{ github.ref == 'refs/heads/master' }}
79+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.ref == 'refs/heads/master' }}
8080
shell: bash -l {0}
8181
run: |
8282
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
@@ -91,8 +91,15 @@ jobs:
9191
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
9292
git commit -m "Latest docs."
9393
git push tokened_docs gh-pages
94+
- name: Save built docs as an artifact
95+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'}}
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: ${{ env.PACKAGE_NAME }} rendered documentation
99+
path: ~/docs
100+
94101
- name: Publish pull-request docs
95-
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
102+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed' }}
96103
env:
97104
PR_NUM: ${{ github.event.number }}
98105
shell: bash -l {0}
@@ -111,7 +118,7 @@ jobs:
111118
git commit -m "Docs for pull request ${PR_NUM}"
112119
git push tokened_docs gh-pages
113120
- name: Unpublish pull-request docs
114-
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
121+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed' }}
115122
env:
116123
PR_NUM: ${{ github.event.number }}
117124
shell: bash -l {0}
@@ -128,7 +135,7 @@ jobs:
128135
git commit -m "Removing docs for closed pull request ${PR_NUM}"
129136
git push tokened_docs gh-pages
130137
- name: Comment with URL to published pull-request docs
131-
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
138+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed' }}
132139
env:
133140
PR_NUM: ${{ github.event.number }}
134141
uses: mshick/add-pr-comment@v1
@@ -138,7 +145,7 @@ jobs:
138145
repo-token: ${{ secrets.GITHUB_TOKEN }}
139146
repo-token-user-login: 'github-actions[bot]'
140147
- name: Comment with URL about removal of PR docs
141-
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
148+
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed' }}
142149
env:
143150
PR_NUM: ${{ github.event.number }}
144151
uses: mshick/add-pr-comment@v1

0 commit comments

Comments
 (0)