Skip to content

Commit 0c78d16

Browse files
committed
ci: split JupyterBook build and Pages deploy jobs
Build the book on every push and pull request so PRs validate the build without touching GitHub Pages. Move the protected github-pages environment, Pages permissions, and deploy-pages step into a separate deploy job that only runs outside pull requests. Manual workflow_dispatch runs still deploy as before.
1 parent 7ab953c commit 0c78d16

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

‎.github/workflows/renderbook.yml‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,22 @@ on:
1111
- main
1212
workflow_dispatch: # allow manual triggers
1313

14-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1514
permissions:
1615
contents: read
17-
pages: write
18-
id-token: write
1916

20-
# Allow one concurrent deployment
17+
# Cancel superseded PR builds, but never cancel an in-progress Pages deployment
2118
concurrency:
22-
group: "pages"
19+
group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.ref) || 'pages' }}
2320
cancel-in-progress: true
2421

2522
jobs:
26-
render:
27-
environment:
28-
name: github-pages
29-
url: ${{ steps.deployment.outputs.page_url }}
30-
23+
build:
24+
# Compile the book on every push and pull request. PRs stop here.
3125
runs-on: ubuntu-latest
3226

3327
steps:
34-
- uses: actions/checkout@v2
35-
28+
- uses: actions/checkout@v4
29+
3630
- name: Install dependencies
3731
run: |
3832
python3 -m pip install --upgrade pip
@@ -42,16 +36,27 @@ jobs:
4236
run: |
4337
jupyter-book build .
4438
45-
- name: Setup Pages
46-
if: github.event_name == 'push'
47-
uses: actions/configure-pages@v5
48-
49-
- name: Upload artifact
39+
- name: Upload Pages artifact
5040
uses: actions/upload-pages-artifact@v4
5141
with:
5242
path: '_build/html'
53-
43+
44+
deploy:
45+
# Publish only for pushes and manual runs; pull requests never deploy.
46+
if: github.event_name != 'pull_request'
47+
needs: build
48+
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
53+
runs-on: ubuntu-latest
54+
55+
permissions:
56+
pages: write
57+
id-token: write
58+
59+
steps:
5460
- name: Deploy to GitHub Pages
55-
if: github.event_name == 'push'
5661
id: deployment
5762
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)