Skip to content

Unified dependency management for github actions #153

Unified dependency management for github actions

Unified dependency management for github actions #153

Workflow file for this run

# Modified from: https://github.com/choldgraf/deploy_configurations/blob/master/.github/workflows/main.yml
# Note: lint with https://rhysd.github.io/actionlint/
name: Publish JupyterBook to GitHub Pages
on:
push: # trigger build only when push to master
branches:
- main
- test-gh-actions # GH actions test branch
permissions:
id-token: write
pages: write
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10.15
- name: Install Python dependencies
run: |
sudo apt-get install python3-pip
pip install -r requirements.txt
pip install ghp-import
PATH="${PATH}:${HOME}/.local/bin"
- name: Build book HTML
run: |
jupyter-book build ./book
- name: Push built book HTML as artifact
uses: actions/upload-pages-artifact@v3
with:
path: "book/_build/html"
- name: Deploy book HTML to Github Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Install PDF build dependencies
run: |
sudo apt-get update
# TeX tools
sudo apt-get install texlive-latex-base \
texlive-latex-extra \
texlive-fonts-extra \
texlive-xetex latexmk
# Image tools
sudo apt-get install libpng-dev libjpeg-dev libtiff-dev imagemagick
# SVG processing tools
sudo apt-get install inkscape
- name: Build PDF of book
continue-on-error: true
run: |
jupyter-book build book --builder latex
# patch output latex
python ./book/patch.py
# build pdf (sphinx creates a makefile for us)
cd ./book/_build/latex/
echo "Entered LaTeX folder, preparing to build PDF"
make
echo "PDF build successful, uploading artifacts now"
# Output build artifacts for debugging
- uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: latex-build-log
path: ./book/_build/latex/elara-handbook.log
compression-level: 0
- uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: autogenerated-latex-source
path: ./book/_build/latex/elara-handbook.tex
compression-level: 0
- uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: elara-handbook-debug-pdf
path: ./book/_build/latex/elara-handbook.pdf
compression-level: 0
- name: Upload book PDF to Github releases
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
pip install github-release-retry
github-release-retry \
--user elaraproject \
--repo elara-handbook \
--tag_name v0.0.0-$(git rev-parse HEAD | cut -c 1-8) \
--prerelease \
--body_string "Automatically generated from book sources via Github Actions" \
./book/_build/latex/elara-handbook.pdf