Skip to content

Commit 9ac3d43

Browse files
committed
Migrate ci.yml to use composite actions
- Replace conda setup with setup-lecture-env - Replace manual LaTeX install with setup-latex - Replace manual jb builds with build-lectures (PDF, Jupyter, HTML) - Replace manual Netlify deploy with deploy-netlify - Benefits: Automatic caching, cleaner workflow, consistent with cache.yml
1 parent 95044aa commit 9ac3d43

File tree

1 file changed

+56
-36
lines changed

1 file changed

+56
-36
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,84 +6,104 @@ jobs:
66
steps:
77
- name: Checkout
88
uses: actions/checkout@v5
9-
- name: Setup Anaconda
10-
uses: conda-incubator/setup-miniconda@v3
9+
10+
# NEW: Use composite action for environment setup
11+
- name: Setup Lecture Environment
12+
uses: quantecon/actions/setup-lecture-env@main
1113
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
14+
python-version: '3.13'
15+
environment-file: 'environment.yml'
16+
1817
- name: Graphics Support #TODO: Review if graphviz is needed
1918
run: |
2019
sudo apt-get -qq update && sudo apt-get install -y graphviz
21-
- name: Install latex dependencies
22-
run: |
23-
sudo apt-get -qq update
24-
sudo apt-get install -y \
25-
texlive-latex-recommended \
26-
texlive-latex-extra \
27-
texlive-fonts-recommended \
28-
texlive-fonts-extra \
29-
texlive-xetex \
30-
latexmk \
31-
xindy \
32-
dvipng \
33-
cm-super
20+
21+
# NEW: Use composite action for LaTeX setup
22+
- name: Install LaTeX Dependencies
23+
uses: quantecon/actions/setup-latex@main
24+
3425
- name: Display Conda Environment Versions
3526
shell: bash -l {0}
3627
run: conda list
28+
3729
- name: Display Pip Versions
3830
shell: bash -l {0}
3931
run: pip list
32+
4033
- name: Download "build" folder (cache)
4134
uses: dawidd6/action-download-artifact@v11
4235
with:
4336
workflow: cache.yml
4437
branch: main
4538
name: build-cache
4639
path: _build
40+
4741
# Build Assets (Download Notebooks and PDF via LaTeX)
42+
# NEW: Use composite action for PDF build
4843
- name: Build PDF from LaTeX
44+
id: build-pdf
45+
uses: quantecon/actions/build-lectures@main
46+
with:
47+
builder: 'pdflatex'
48+
source-dir: 'lectures'
49+
extra-args: '-n --keep-going'
50+
51+
- name: Copy LaTeX PDF for GH-PAGES
4952
shell: bash -l {0}
5053
run: |
51-
jb build lectures --builder pdflatex --path-output ./ -n --keep-going
5254
mkdir -p _build/html/_pdf
5355
cp -u _build/latex/*.pdf _build/html/_pdf
56+
5457
- name: Upload Execution Reports (LaTeX)
5558
uses: actions/upload-artifact@v5
5659
if: failure()
5760
with:
58-
name: execution-reports
61+
name: execution-reports-latex
5962
path: _build/latex/reports
63+
64+
# NEW: Use composite action for Jupyter build
6065
- name: Build Download Notebooks (sphinx-tojupyter)
66+
id: build-jupyter
67+
uses: quantecon/actions/build-lectures@main
68+
with:
69+
builder: 'jupyter'
70+
source-dir: 'lectures'
71+
extra-args: ''
72+
73+
- name: Copy Download Notebooks for GH-PAGES
6174
shell: bash -l {0}
6275
run: |
63-
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter
6476
mkdir -p _build/html/_notebooks
6577
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
78+
6679
# Build HTML (Website)
6780
# BUG: rm .doctress to remove `sphinx` rendering issues for ipywidget mimetypes
6881
# and clear the sphinx cache for building final HTML documents.
82+
- name: Remove doctrees cache
83+
run: rm -r _build/.doctrees
84+
85+
# NEW: Use composite action for HTML build
6986
- name: Build HTML
70-
shell: bash -l {0}
71-
run: |
72-
rm -r _build/.doctrees
73-
jb build lectures --path-output ./ -nW --keep-going
87+
id: build-html
88+
uses: quantecon/actions/build-lectures@main
89+
with:
90+
builder: 'html'
91+
source-dir: 'lectures'
92+
extra-args: '-nW --keep-going'
93+
7494
- name: Upload Execution Reports (HTML)
7595
uses: actions/upload-artifact@v5
7696
if: failure()
7797
with:
78-
name: execution-reports
98+
name: execution-reports-html
7999
path: _build/html/reports
100+
101+
# NEW: Use composite action for Netlify deployment
80102
- name: Preview Deploy to Netlify
81-
uses: nwtgck/actions-netlify@v3.0
103+
uses: quantecon/actions/deploy-netlify@main
82104
with:
83-
publish-dir: '_build/html/'
84-
production-branch: main
105+
netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
106+
netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
107+
build-dir: ${{ steps.build-html.outputs.build-path }}
108+
production: 'false'
85109
github-token: ${{ secrets.GITHUB_TOKEN }}
86-
deploy-message: "Preview Deploy from GitHub Actions"
87-
env:
88-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
89-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

0 commit comments

Comments
 (0)