Skip to content

Commit bfcd523

Browse files
committed
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
1 parent c1b8dbe commit bfcd523

4 files changed

Lines changed: 193 additions & 0 deletions

File tree

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