|
1 | 1 | # Simple workflow for deploying static content to GitHub Pages |
2 | | -name: Deploy static content to Pages |
| 2 | +name: Build docs |
3 | 3 |
|
4 | 4 | on: |
5 | | - # Runs on pushes targeting the default branch |
6 | | - push: |
7 | | - branches: |
8 | | - - "**" |
9 | | - |
10 | | - # Allows you to run this workflow manually from the Actions tab |
11 | 5 | workflow_dispatch: |
12 | | - |
13 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
14 | | -permissions: |
15 | | - contents: read |
16 | | - pages: write |
17 | | - id-token: write |
18 | | - |
19 | | -# Allow one concurrent deployment |
20 | | -concurrency: |
21 | | - group: "pages" |
22 | | - cancel-in-progress: true |
| 6 | + workflow_call: |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
23 | 10 |
|
24 | 11 | jobs: |
25 | | - build: |
26 | | - runs-on: ubuntu-latest |
| 12 | + build_docs: |
| 13 | + runs-on: ubuntu-22.04 |
27 | 14 | env: |
28 | | - # Directory that will be published on github pages |
| 15 | + PYTHON_VERSION: "3.10" |
29 | 16 | PUBLISH_DIR: ./_build/html |
30 | 17 |
|
31 | 18 | steps: |
| 19 | + # checkout the repository |
32 | 20 | - uses: actions/checkout@v4 |
33 | 21 |
|
34 | | - - name: Setup Python |
| 22 | + # setup Python |
| 23 | + - name: Install Python ${{ env.PYTHON_VERSION }} |
35 | 24 | uses: actions/setup-python@v4 |
36 | 25 | with: |
37 | | - python-version: "3.10" |
| 26 | + python-version: ${{ env.PYTHON_VERSION }} |
38 | 27 |
|
39 | | - - name: Cache |
40 | | - id: cache |
| 28 | + # preserve pip cache to speed up installation |
| 29 | + - name: Cache pip |
41 | 30 | uses: actions/cache@v3 |
42 | 31 | with: |
43 | | - path: | |
44 | | - ~/.cache/pip |
45 | | - ~/_build |
46 | | - key: cache_v1 |
| 32 | + path: ~/.cache/pip |
| 33 | + # Look to see if there is a cache hit for the corresponding requirements file |
| 34 | + key: ${{ runner.os }}-pip-${{ hashFiles('*requirements-docs.txt') }} |
47 | 35 | restore-keys: | |
48 | | - cache_v1 |
49 | | -
|
50 | | - - name: Install dependencies |
51 | | - run: python3 -m pip install -r requirements-docs.txt |
52 | | - |
| 36 | + ${{ runner.os }}-pip- |
| 37 | + - name: Install Python dependencies |
| 38 | + run: | |
| 39 | + python3 -m pip install --upgrade pip |
| 40 | + python3 -m pip install -r requirements-docs.txt |
53 | 41 |
|
54 | 42 | - name: Build docs |
55 | | - run: jupyter book build . |
| 43 | + run: python3 -m jupyter book build . |
56 | 44 |
|
57 | 45 | - name: Upload artifact |
58 | 46 | uses: actions/upload-pages-artifact@v2 |
59 | 47 | with: |
| 48 | + name: documentation |
60 | 49 | path: ${{ env.PUBLISH_DIR }} |
61 | | - |
62 | | - # Single deploy job since we're just deploying |
63 | | - deploy: |
64 | | - if: github.ref == 'refs/heads/main' |
65 | | - needs: build |
66 | | - environment: |
67 | | - name: github-pages |
68 | | - url: ${{ steps.deployment.outputs.page_url }} |
69 | | - |
70 | | - runs-on: ubuntu-latest |
71 | | - |
72 | | - steps: |
73 | | - - name: Checkout |
74 | | - uses: actions/checkout@v4 |
75 | | - |
76 | | - - name: Setup Pages |
77 | | - uses: actions/configure-pages@v3 |
78 | | - |
79 | | - |
80 | | - - name: Deploy to GitHub Pages |
81 | | - id: deployment |
82 | | - uses: actions/deploy-pages@v2 |
| 50 | + if-no-files-found: error |
0 commit comments