Merge pull request #70 from ANU-RSES-Education/updates-23July2024 #114
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy-book | |
# Only run this when the master branch changes (or by hand) | |
on: | |
push: | |
branches: | |
- master | |
- jupyterbook | |
workflow_dispatch: | |
# If your git repository has the Jupyter Book within some-subfolder next to | |
# unrelated files, you can make this run only if a file within that specific | |
# folder has been modified. | |
# | |
# paths: | |
# - some-subfolder/** | |
# This job installs dependencies, build the book, and pushes it to `gh-pages` | |
jobs: | |
deploy-book: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
# Install dependencies | |
# - name: Set up Python 3.7 | |
# uses: actions/setup-python@v1 | |
# with: | |
# python-version: 3.7 | |
- name: Cache book files | |
uses: actions/cache@v1 | |
env: | |
# Increase this value to reset cache if etc/example-environment.yml has not changed | |
CACHE_NUMBER: 2 | |
with: | |
path: | | |
~/conda_pkgs_dir | |
/usr/share/miniconda3/envs/jupyter | |
~/.cache/pip | |
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda_packages.yml') }} | |
- name: switch base env name to something other than 'base' | |
run: | | |
sed 's/name: base/name: jupyter/' conda_packages.yml > conda_jupyter_env.yml | |
# - name: Miniconda / Miniforge | |
# uses: conda-incubator/setup-miniconda@v3 | |
# with: | |
# miniconda-version: latest | |
# environment-file: conda_jupyter_env.yml | |
# activate-environment: jupyter | |
# python-version: 3.9 | |
# use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly! | |
- name: Add micromamba | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
micromamba-version: "1.5.6-0" # any version from https://github.com/mamba-org/micromamba-releases | |
environment-file: conda_jupyter_env.yml | |
init-shell: bash | |
cache-environment: true | |
post-cleanup: "all" | |
# Would be helpful to cache some of the installation | |
- name: Install pip dependencies | |
shell: bash -l {0} | |
run: | | |
# sed '/^[[:blank:]]*#/d;s/#.*//' apt_get_packages.txt > apt_get_packages_no_comment.txt | |
# sudo xargs apt-get -y install < apt_get_packages_no_comment.txt | |
# Conda cache will not catch the pip installations (need to do this separately) | |
pip install jupyter-book | |
npm install -g reveal-md | |
# Build the book | |
- name: Build the book | |
shell: bash -l {0} | |
run: | | |
cd Jupyterbook | |
source build_book.sh | |
# Push the book's HTML to github-pages | |
- name: GitHub Pages action | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: Jupyterbook/_build/html |