Skip to content

Commit d2bbd42

Browse files
authored
Merge pull request #9 from scientificcomputing/fix-build-docs-workflow
Add build and deploy workflows for docs
2 parents e9323c6 + 75c224d commit d2bbd42

File tree

2 files changed

+76
-57
lines changed

2 files changed

+76
-57
lines changed

.github/workflows/build_docs.yml

Lines changed: 25 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,50 @@
11
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
2+
name: Build docs
33

44
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
115
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
2310

2411
jobs:
25-
build:
26-
runs-on: ubuntu-latest
12+
build_docs:
13+
runs-on: ubuntu-22.04
2714
env:
28-
# Directory that will be published on github pages
15+
PYTHON_VERSION: "3.10"
2916
PUBLISH_DIR: ./_build/html
3017

3118
steps:
19+
# checkout the repository
3220
- uses: actions/checkout@v4
3321

34-
- name: Setup Python
22+
# setup Python
23+
- name: Install Python ${{ env.PYTHON_VERSION }}
3524
uses: actions/setup-python@v4
3625
with:
37-
python-version: "3.10"
26+
python-version: ${{ env.PYTHON_VERSION }}
3827

39-
- name: Cache
40-
id: cache
28+
# preserve pip cache to speed up installation
29+
- name: Cache pip
4130
uses: actions/cache@v3
4231
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') }}
4735
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
5341
5442
- name: Build docs
55-
run: jupyter book build .
43+
run: python3 -m jupyter book build .
5644

5745
- name: Upload artifact
5846
uses: actions/upload-pages-artifact@v2
5947
with:
48+
name: documentation
6049
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

.github/workflows/deploy_docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Github Pages
2+
3+
on:
4+
push:
5+
branches: [main] # Only run on push to main
6+
7+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
# Allow one concurrent deployment
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build-docs:
20+
uses: ./.github/workflows/build_docs.yml
21+
22+
deploy:
23+
needs: [build-docs]
24+
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Download docs artifact
32+
# docs artifact is uploaded by build-docs job
33+
uses: actions/download-artifact@v3
34+
with:
35+
name: documentation
36+
path: "./public"
37+
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v2
40+
with:
41+
path: "./public"
42+
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v3
48+
49+
- name: Deploy to GitHub Pages
50+
id: deployment
51+
uses: actions/deploy-pages@v2

0 commit comments

Comments
 (0)