Skip to content

Commit ff4f82b

Browse files
authored
Add GitHub Pages build and deploy workflows (#22)
* Add GitHub Pages build and deploy workflows - Add environment.yml (Anaconda-based, matching upstream lecture-python-programming) - Add cache.yml workflow for weekly notebook execution cache - Add ci.yml workflow for PR preview builds - Add publish.yml workflow for tag-based deploy to GitHub Pages * Address Copilot review feedback - Fix conda channel name: 'default' -> 'defaults' - Add permissions block to ci.yml (actions: read for artifact download) - Tighten publish.yml permissions: contents: write -> contents: read
1 parent c1b8dbe commit ff4f82b

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed

.github/workflows/cache.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build Cache [using jupyter-book]
2+
on:
3+
schedule:
4+
# Execute cache weekly at 3am on Monday
5+
- cron: '0 3 * * 1'
6+
workflow_dispatch:
7+
8+
jobs:
9+
cache:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.13"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install JAX (CPU)
23+
shell: bash -l {0}
24+
run: |
25+
pip install jax
26+
- name: Display Conda Environment Versions
27+
shell: bash -l {0}
28+
run: conda list
29+
- name: Display Pip Versions
30+
shell: bash -l {0}
31+
run: pip list
32+
- name: Build HTML
33+
shell: bash -l {0}
34+
run: |
35+
jb build lectures --path-output ./ -W --keep-going
36+
- name: Upload Execution Reports
37+
uses: actions/upload-artifact@v4
38+
if: failure()
39+
with:
40+
name: execution-reports
41+
path: _build/html/reports
42+
- name: Upload "_build" folder (cache)
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: build-cache
46+
path: _build
47+
include-hidden-files: true

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build Project [using jupyter-book]
2+
on: [pull_request]
3+
4+
permissions:
5+
contents: read
6+
actions: read
7+
8+
jobs:
9+
preview:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.13"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install JAX (CPU)
23+
shell: bash -l {0}
24+
run: |
25+
pip install jax
26+
- name: Display Conda Environment Versions
27+
shell: bash -l {0}
28+
run: conda list
29+
- name: Display Pip Versions
30+
shell: bash -l {0}
31+
run: pip list
32+
- name: Download "build" folder (cache)
33+
uses: dawidd6/action-download-artifact@v6
34+
with:
35+
workflow: cache.yml
36+
branch: main
37+
name: build-cache
38+
path: _build
39+
# Build Assets (Download Notebooks)
40+
- name: Build Download Notebooks (sphinx-tojupyter)
41+
shell: bash -l {0}
42+
run: |
43+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
44+
mkdir -p _build/html/_notebooks
45+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
46+
# Final Build of HTML
47+
- name: Build HTML
48+
shell: bash -l {0}
49+
run: |
50+
jb build lectures --path-output ./ -n -W --keep-going
51+
- name: Upload Execution Reports
52+
uses: actions/upload-artifact@v4
53+
if: failure()
54+
with:
55+
name: execution-reports
56+
path: _build/html/reports

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build & Publish to GH Pages
2+
on:
3+
push:
4+
tags:
5+
- 'publish*'
6+
7+
permissions:
8+
contents: read
9+
actions: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
publish:
19+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- name: Setup Anaconda
28+
uses: conda-incubator/setup-miniconda@v3
29+
with:
30+
auto-update-conda: true
31+
auto-activate-base: true
32+
miniconda-version: 'latest'
33+
python-version: "3.13"
34+
environment-file: environment.yml
35+
activate-environment: quantecon
36+
- name: Install JAX (CPU)
37+
shell: bash -l {0}
38+
run: |
39+
pip install jax
40+
- name: Display Conda Environment Versions
41+
shell: bash -l {0}
42+
run: conda list
43+
- name: Display Pip Versions
44+
shell: bash -l {0}
45+
run: pip list
46+
# Download Build Cache from cache.yml
47+
- name: Download "build" folder (cache)
48+
uses: dawidd6/action-download-artifact@v6
49+
with:
50+
workflow: cache.yml
51+
branch: main
52+
name: build-cache
53+
path: _build
54+
# Build Assets (Download Notebooks)
55+
- name: Build Download Notebooks (sphinx-tojupyter)
56+
shell: bash -l {0}
57+
run: |
58+
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
59+
mkdir -p _build/html/_notebooks
60+
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
61+
# Final Build of HTML (with assets)
62+
- name: Build HTML
63+
shell: bash -l {0}
64+
run: |
65+
jb build lectures --path-output ./ -n -W --keep-going
66+
- name: Upload Execution Reports
67+
uses: actions/upload-artifact@v4
68+
if: failure()
69+
with:
70+
name: execution-reports
71+
path: _build/html/reports
72+
- name: Setup Pages
73+
uses: actions/configure-pages@v4
74+
- name: Upload Pages artifact
75+
uses: actions/upload-pages-artifact@v3
76+
with:
77+
path: _build/html/
78+
- name: Deploy to GitHub Pages
79+
id: deployment
80+
uses: actions/deploy-pages@v4

environment.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: quantecon
2+
channels:
3+
- defaults
4+
dependencies:
5+
- python=3.13
6+
- anaconda=2025.12
7+
- pip
8+
- pip:
9+
- jupyter-book>=1.0.4post1,<2.0
10+
- quantecon-book-theme==0.20.0
11+
- sphinx-tojupyter==0.6.0
12+
- sphinxext-rediraffe==0.3.0
13+
- sphinx-exercise==1.2.1
14+
- sphinx-togglebutton==0.4.5

0 commit comments

Comments
 (0)