Skip to content

Commit c3bf689

Browse files
committed
Make a document preview for PRs
Make it much easier for reviewing changes on docs. Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
1 parent 08e5f92 commit c3bf689

2 files changed

Lines changed: 46 additions & 12 deletions

File tree

.github/workflows/pages.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
1515
cancel-in-progress: true
1616

17-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17+
# contents: write required to push to gh-pages branch
1818
permissions:
19-
contents: read
20-
pages: write
21-
id-token: write
19+
contents: write
2220

2321
jobs:
2422
build-docs:
@@ -30,18 +28,26 @@ jobs:
3028
- name: Build docs
3129
run: pip install tox && tox -e build-docs
3230
- name: Upload docs artifact
33-
if: github.event_name == 'push'
34-
uses: actions/upload-pages-artifact@v4
31+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
32+
uses: actions/upload-artifact@v4
3533
with:
34+
name: docs-html
3635
path: docs/build/html
3736

3837
deploy-gh-pages:
39-
if: github.event_name == 'push'
38+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
4039
needs: build-docs
4140
runs-on: ubuntu-latest
42-
environment:
43-
name: github-pages
44-
url: ${{ steps.deployment.outputs.page_url }}
4541
steps:
46-
- id: deployment
47-
uses: actions/deploy-pages@v4
42+
- uses: actions/checkout@v6
43+
- name: Download docs artifact
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: docs-html
47+
path: docs/build/html
48+
- name: Deploy to GitHub Pages
49+
uses: JamesIves/github-pages-deploy-action@v4
50+
with:
51+
folder: docs/build/html
52+
# Preserve PR preview subdirectories deployed by pr-preview.yml
53+
clean-exclude: pr-preview

.github/workflows/pr-preview.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: PR Docs Preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, closed]
6+
branches: [main, release/*, feature/*]
7+
8+
# One preview deployment per PR; do not cancel so 'closed' cleanup always runs
9+
concurrency: pr-preview-${{ github.event.pull_request.number }}
10+
11+
permissions:
12+
contents: write # push preview to gh-pages branch
13+
pull-requests: write # post/update preview URL comment on the PR
14+
15+
jobs:
16+
deploy-preview:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 30
19+
steps:
20+
- uses: actions/checkout@v6
21+
- uses: ./.github/actions/ubuntu-setup
22+
- name: Build docs
23+
if: github.event.action != 'closed'
24+
run: pip install tox && tox -e build-docs
25+
- name: Deploy / remove PR preview
26+
uses: rossjrw/pr-preview-action@v1
27+
with:
28+
source-dir: docs/build/html

0 commit comments

Comments
 (0)