-
Notifications
You must be signed in to change notification settings - Fork 3
83 lines (71 loc) · 3.28 KB
/
book_stable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Test stable build of book
on:
workflow_dispatch:
workflow_call:
pull_request:
branches: ["main", "release"]
push:
branches: ["main"] # this also gets called by deploy on push into release
permissions:
contents: read
actions: write
env:
HDF5_MPI: "ON"
HDF5_DIR: "/usr/local/"
DISPLAY: ":99.0"
DEB_PYTHON_INSTALL_LAYOUT: deb_system
jobs:
build-book:
runs-on: ubuntu-latest
container: ghcr.io/cianwilson/fenics-sz:release
env:
PYVISTA_TRAME_SERVER_PROXY_PREFIX: "/proxy/"
PYVISTA_TRAME_SERVER_PROXY_ENABLED: "True"
PYVISTA_OFF_SCREEN: false
PYVISTA_JUPYTER_BACKEND: "html"
BASE_NAME: ${{ github.base_ref || github.ref_name }}
HEAD_NAME: ${{ github.head_ref || github.ref_name }}
steps:
- uses: actions/checkout@v4
# Restore the cache, either from this branch or, as a backup, use the base branch
# We don't use the cache on pushes or deployment calls to the release branch
- name: Restore cache
id: cache-restore
uses: actions/cache/restore@v4
if: env.BASE_NAME != 'release' || github.event_name == 'pull_request'
with:
path: _build/.jupyter_cache
key: jupyter-book-cache-${{ env.HEAD_NAME }}-${{ hashFiles('notebooks/sz_base.ipynb', 'notebooks/sz_slab.ipynb', 'notebooks/sz_geometry.ipynb', 'notebooks/sz_problem.ipynb', 'python/geometry.py', 'python/utils.py') }}
restore-keys: jupyter-book-cache-${{ env.BASE_NAME }}-${{ hashFiles('notebooks/sz_base.ipynb', 'notebooks/sz_slab.ipynb', 'notebooks/sz_geometry.ipynb', 'notebooks/sz_problem.ipynb', 'python/geometry.py', 'python/utils.py') }}
# Build the book
- name: Build the book
run: jupyter-book build . -W --keep-going
# Upload the book html
- uses: actions/upload-artifact@v4
if : always()
with:
name: webpage
path: ./_build/html
retention-days: 2
if-no-files-found: error
# Delete the previous cache so we can upload a new one
# This is currently unsupported by the cache action so we have to
# do it using the gh command
# Based on https://github.com/azu/github-actions-overwrite-cache-example
- name: Delete previous cache
if: env.BASE_NAME != 'release' || github.event_name == 'pull_request'
continue-on-error: true
run: |
git config --global --add safe.directory /__w/fenics-sz/fenics-sz
gh extension install actions/gh-actions-cache
gh actions-cache delete jupyter-book-cache-${{ env.HEAD_NAME }}-${{ hashFiles('notebooks/sz_base.ipynb', 'notebooks/sz_slab.ipynb', 'notebooks/sz_geometry.ipynb', 'notebooks/sz_problem.ipynb', 'python/geometry.py', 'python/utils.py') }} --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # this isn't publicly visible
# Save our cache
- name: Save cache
uses: actions/cache/save@v4
if: env.BASE_NAME != 'release' || github.event_name == 'pull_request'
continue-on-error: true
with:
path: _build/.jupyter_cache
key: jupyter-book-cache-${{ env.HEAD_NAME }}-${{ hashFiles('notebooks/sz_base.ipynb', 'notebooks/sz_slab.ipynb', 'notebooks/sz_geometry.ipynb', 'notebooks/sz_problem.ipynb', 'python/geometry.py', 'python/utils.py') }}