-
Notifications
You must be signed in to change notification settings - Fork 43
135 lines (129 loc) · 4.92 KB
/
buildbook.yaml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: buildbook
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
env:
# Increase this value to reset cache
CONDA_CACHE_NUMBER: 0
PYDEVD_DISABLE_FILE_VALIDATION: 1 # disable warnings that debugger might not work using frozen (i.e. faster-to-load) modules. We'd expect debugging to be done outside of CI, so here it's probably fine to hide it.
jobs:
build:
# Only run scheduled jobs on the upstream repo
if: github.repository == 'orcestra-campaign/book' || github.event_name != 'schedule'
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- name: initialize conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: orcestra_book
auto-activate-base: false
use-mamba: true
miniforge-version: latest
- name: restore conda environment from cache
uses: actions/cache/restore@v4
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{ hashFiles('environment.yml') }}-${{ env.CONDA_CACHE_NUMBER }}
id: conda_cache
- name: install conda environment
run:
mamba env update -n orcestra_book -f environment.yml
if: steps.conda_cache.outputs.cache-hit != 'true'
id: install_conda_env
- name: upload conda environment to cache
uses: actions/cache/save@v4
if: steps.install_conda_env.outcome == 'success'
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}--${{ runner.arch }}--${{ hashFiles('environment.yml') }}-${{ env.CONDA_CACHE_NUMBER }}
- name: install IPFS
run: |
wget -q https://dist.ipfs.tech/kubo/${IPFS_VERSION}/kubo_${IPFS_VERSION}_linux-amd64.tar.gz
tar -xvzf kubo_${IPFS_VERSION}_linux-amd64.tar.gz
pushd kubo
sudo bash install.sh
popd
ipfs --version
env:
IPFS_VERSION: v0.32.1
- name: init IPFS
run: |
ipfs init --profile server,announce-off
- name: configure known IPFS peers
run: |
wget -q https://raw.githubusercontent.com/orcestra-campaign/ipfs_tools/refs/heads/main/scripts/add_peers.py -O - | python - -f https://raw.githubusercontent.com/orcestra-campaign/ipfs_tools/refs/heads/main/known_peers.yaml
- name: run IPFS in background
run: |
ipfs daemon 2>ipfs.log | grep -i -o -m1 'Daemon is ready' & tail -F --pid=$! ipfs.log
- name: setting up notebook execution cache
uses: actions/cache/restore@v4
with:
path: |
orcestra_book/_build/.jupyter_cache
key: notebooks-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
notebooks-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ github.run_id }}-
notebooks-${{ runner.os }}-${{ hashFiles('environment.yml') }}-
- name: Invalidate EarthCARE cache
if: github.event_name == 'schedule'
# Invalidate the cache for the EarthCARE track to always show the latest prediction
run: jcache notebook -p orcestra_book/_build/.jupyter_cache/ invalidate orcestra_book/earthcare.md
- name: build book
run: |
conda info
jupyter-book build -W -n --keep-going orcestra_book
- name: save execution cache
uses: actions/cache/save@v4
if: always()
with:
path: |
orcestra_book/_build/.jupyter_cache
key: notebooks-${{ runner.os }}-${{ hashFiles('environment.yml') }}-${{ github.run_id }}-${{ github.run_attempt }}
- name: Archive build artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: html
path: |
orcestra_book/_build/html
publish:
needs: build
if: "always() && github.repository_owner == 'orcestra-campaign' && (github.event_name == 'schedule' || (github.event_name == 'push' && github.ref == 'refs/heads/main'))"
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
steps:
- name: Download compiled book
uses: actions/download-artifact@v4
with:
name: html
path: html
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'html'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4