Skip to content

Update build-static.yml #132

Update build-static.yml

Update build-static.yml #132

Workflow file for this run

name: deploy-jupyterbook-website
# Relevant docs: https://docs.github.com/en/actions/learn-github-actions/
# Specifically 'contexts' (`${{ github. }}`) and 'environment variables'.
on:
push:
branches: [ "main" ]
workflow_dispatch: {}
# Allow triggering this workflow manually, from the Actions tab.
jobs:
build-and-deploy:
runs-on: ubuntu-latest
defaults:
run:
shell: bash --login {0}
# The default shell on github actions is a non-login shell,
# but to make `conda activate` work, we need a login shell:
# https://github.com/conda-incubator/setup-miniconda#important
# (No idea what `{0}` is).
steps:
- name: Download repo # ..to $GITHUB_WORKSPACE directory, aka cwd.
uses: actions/checkout@v3
- name: Set-up conda (Miniforge) & create empty env
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-version: latest
activate-environment: comob-soundloc-web
# this will be the activated conda env for `run` commands in subsequent steps.
# Creating a conda env from .yml file on gh actions takes ~1m46s, while other steps
# take just 1s (gh-pages) to 3s (build.py). So, we cache package version resolving,
# downloading & unpacking, for faster deploys. See
# https://github.com/marketplace/actions/setup-miniconda#caching-environments
- name: Cache conda package installation
id: cache-conda-package-install
uses: actions/cache@v3
with:
path: ${{ env.CONDA }}/envs # Cached dir.
key: ${{ hashFiles('web/conda-environment.yml') }}
# Invalidate cache if the contents (and thus hash) of this file change.
- name: Install packages in our conda env
# ..but only if this is not already done by restoring the cached dir.
if: steps.cache-conda-package-install.outputs.cache-hit != 'true'
run: conda env update -f web/conda-environment.yml
- name: Log env info
run: |
conda info
conda list
- name: Run build script
run: python web/build.py
- name: Push html to gh-pages branch.
uses: peaceiris/actions-gh-pages@v3 # https://github.com/peaceiris/actions-gh-pages
with:
publish_dir: web/_generated/_build/html
commit_message: deploy ${{ github.sha }} (${{ github.event.head_commit.message }})
github_token: ${{ secrets.GITHUB_TOKEN }}