MNT: Use hash for Action workflow versions and update if needed #187
Workflow file for this run
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
# GitHub Actions workflow for testing and continuous integration. | |
# | |
# This file performs testing using tox and tox.ini to define and configure the test environments. | |
name: Build and Deploy Book | |
on: | |
push: | |
branches: | |
- main # GitHub now defaults to 'main' as the name of the primary branch. Change this as needed. | |
tags: # run CI if specific tags are pushed | |
- '[0-9]+.[0-9]+.[0-9]+[a-z0-9]*' # pre-releases -- note that brackets only | |
# match single character, and that * does | |
# not mean zero or more of previous | |
# character. | |
- '[0-9]+.[0-9]+.[0-9]+' # actual releases. | |
pull_request: | |
branches: # only build on PRs against 'main' | |
- main | |
jobs: | |
# Github Actions supports ubuntu, windows, and macos virtual environments: | |
# https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners | |
build_book: | |
name: ${{ matrix.name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- name: Build book | |
os: ubuntu-latest | |
python: 3.11 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
with: | |
fetch-depth: 0 | |
- name: Setup Miniconda | |
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0 | |
with: | |
python-version: ${{ matrix.python }} | |
auto-update-conda: true | |
- name: Install base dependencies | |
shell: bash -l {0} | |
run: | | |
conda install -c conda-forge mamba | |
mamba install --quiet -c conda-forge astroquery ccdproc photutils sphinx sphinxcontrib-bibtex jupyter-book=0.13.2 | |
conda list | |
python -m pip install lxml_html_clean | |
conda info -e | |
# python -m pip install jupyter-book==0.12.1 | |
- name: Cache | |
id: cache | |
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 | |
with: | |
path: | | |
notebooks/*.fit*.bz | |
notebooks/example-cryo-LFC | |
notebooks/example-thermo-electric | |
notebooks/download_data.py | |
key: ${{ hashFiles('notebooks/*.fit*.bz', 'notebooks/example-cryo-LFC', 'notebooks/example-thermo-electric', 'notebooks/download_data.py') }} | |
- name: Download data | |
if: steps.cache.outputs.cache-hit != 'true' | |
shell: bash -l {0} | |
run: | | |
cd notebooks | |
python download_data.py | |
- name: Build book | |
shell: bash -l {0} | |
run: | | |
export GUIDE_RANDOM_SEED=4920385 # Use a seed to minimize changes in images | |
jb build . | |
- name: Upload HTML | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
with: | |
name: rendered-book-sha-${{ github.sha }} | |
path: | | |
_build/html | |
deploy_html: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: build_book | |
if: ${{ github.ref == 'refs/heads/main' || contains(github.ref, 'tags') }} | |
steps: | |
- name: Set version number | |
run: | | |
VERSION_NUMBER=${GITHUB_REF#refs/tags/} | |
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then VERSION_NUMBER=dev; fi | |
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV | |
- name: Download artifact | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
name: rendered-book-sha-${{ github.sha }} | |
path: dev | |
- name: Deploy pages | |
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: dev | |
destination_dir: v/${{ env.VERSION_NUMBER }} |