|
1 | | -name: CI |
| 1 | +name: deploy-book |
2 | 2 |
|
3 | | -on: |
| 3 | +# Run this when the master or main branch changes |
| 4 | +on: |
4 | 5 | push: |
5 | | - branches: |
| 6 | + branches: |
6 | 7 | - master |
| 8 | + - main |
| 9 | + # If your git repository has the Jupyter Book within some-subfolder next to |
| 10 | + # unrelated files, you can make this run only if a file within that specific |
| 11 | + # folder has been modified. |
| 12 | + # |
| 13 | + # paths: |
| 14 | + # - some-subfolder/** |
7 | 15 |
|
| 16 | +# This job installs dependencies, builds the book, and pushes it to `gh-pages` |
8 | 17 | jobs: |
9 | | - build: |
| 18 | + deploy-book: |
10 | 19 | runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + pages: write |
| 22 | + id-token: write |
11 | 23 | steps: |
12 | | - - uses: actions/checkout@v4 |
| 24 | + - uses: actions/checkout@v5 |
13 | 25 |
|
14 | | - - name: Setup Python |
15 | | - uses: actions/setup-python@v5 |
| 26 | + # Install dependencies |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v6 |
16 | 29 | with: |
17 | | - python-version: '3.10' |
18 | | - |
19 | | - - name: install |
| 30 | + python-version: "3.13" |
| 31 | + cache: pip # Implicitly uses requirements.txt for cache key |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: pip install -r requirements.txt |
| 35 | + |
| 36 | + # (optional) Cache your executed notebooks between runs |
| 37 | + # if you have config: |
| 38 | + # execute: |
| 39 | + # execute_notebooks: cache |
| 40 | + - name: cache executed notebooks |
| 41 | + uses: actions/cache@v4 |
| 42 | + with: |
| 43 | + path: _build/.jupyter_cache |
| 44 | + key: jupyter-book-cache-${{ hashFiles('requirements.txt') }} |
| 45 | + |
| 46 | + # Build the book |
| 47 | + - name: Build the book |
20 | 48 | run: | |
21 | | - python --version |
22 | | - python -m pip install setuptools |
23 | | - python -m pip install -r requirements.txt |
24 | | - |
25 | | - - name: build |
26 | | - env: |
27 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | | - run: | |
29 | | - |
30 | | - cd $GITHUB_WORKSPACE |
31 | | - git init |
32 | | - git config user.name "Github Actions" |
33 | | - git config user.email "[email protected]" |
34 | | - REPOSITORY_PATH="https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" |
35 | | - |
36 | | - git checkout master |
37 | 49 | jupyter-book build . |
38 | 50 |
|
39 | | - - name: Deploy |
40 | | - uses: peaceiris/actions-gh-pages@v3 |
| 51 | + # https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow |
| 52 | + |
| 53 | + # Upload the book's HTML as an artifact |
| 54 | + - name: Upload artifact |
| 55 | + uses: actions/upload-pages-artifact@v4 |
41 | 56 | with: |
42 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
43 | | - force_orphan: true |
44 | | - publish_dir: ./_build/html |
| 57 | + path: _build/html |
| 58 | + |
| 59 | + # Deploy the book's HTML to GitHub Pages |
| 60 | + - name: Deploy to GitHub Pages |
| 61 | + id: deployment |
| 62 | + uses: actions/deploy-pages@v4 |
0 commit comments