Skip to content

Wednesday's notes

Wednesday's notes #23

Workflow file for this run

name: deploy-book
# Run this when the master or main branch changes
on:
push:
branches:
- master
- main
# 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, builds the book, and pushes it to `gh-pages`
jobs:
deploy-book:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
# Install dependencies
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Read Julia version
id: read_toml
run: echo value=$(python -c 'import tomllib; from pathlib import Path; print(tomllib.loads(Path("Manifest.toml").read_text())["julia_version"])') >> "$GITHUB_OUTPUT"
- name: Get environment hash
id: hash
run: |
echo "value=${{ hashFiles('Project.toml', 'Manifest.toml', 'src/**') }}" >> "$GITHUB_OUTPUT"
echo "ver=${{ runner.os }}-julia-${{ steps.read_toml.outputs.value }}" >> "$GITHUB_OUTPUT"
- name: Cache executed notebooks
uses: actions/cache@v4
id: cache-nb
with:
path: |
${{ env.NBCACHE }}/**/*.ipynb
${{ env.NBCACHE }}/**/*.sha
key: notebook-${{ steps.hash.outputs.value }}-${{ hashFiles('docs/**/*.ipynb', 'docs/**/*.jl') }}
restore-keys: |
notebook-${{ steps.hash.outputs.value }}-
- name: Setup Julia
uses: julia-actions/setup-julia@v2
with:
version: ${{ steps.read_toml.outputs.value }}
- name: Restore Julia packages
uses: actions/cache/restore@v4
if: ${{ runner.environment == 'github-hosted' }}
id: cache-julia
with:
path: ~/.julia
key: ${{ steps.hash.outputs.ver }}-${{ steps.hash.outputs.value }}
restore-keys: |
${{ steps.hash.outputs.ver }}-
- name: Install Julia packages
if: ${{ runner.environment == 'self-hosted' || steps.cache-julia.outputs.cache-hit != 'true' }}
shell: julia --color=yes {0}
env:
JUPYTER: 'jupyter'
run: |
using Pkg
Pkg.add(["IJulia", "Literate", "Tables", "MarkdownTables", "JSON"])
Pkg.activate(".")
Pkg.instantiate()
Pkg.precompile()
- name: Clean Julia package directory
if: ${{ runner.environment == 'github-hosted' && steps.cache-julia.outputs.cache-hit != 'true' }}
shell: julia --color=yes {0}
run: |
using Pkg, Dates
Pkg.gc(collect_delay=Day(0))
- name: Save Julia packages
uses: actions/cache/save@v4
if: ${{ runner.environment == 'github-hosted' && steps.cache-julia.outputs.cache-hit != 'true' }}
with:
path: ~/.julia
key: ${{ steps.cache-julia.outputs.cache-primary-key }}
- name: Install kernel
run: ipython kernel install --name "julia-1.11" --user
- name: Build website
run: jupyter-book build .
# Upload the book's HTML as an artifact
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "_build/html"
# Deploy the book's HTML to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2