-
Notifications
You must be signed in to change notification settings - Fork 9
154 lines (131 loc) · 4.24 KB
/
docs.yaml
File metadata and controls
154 lines (131 loc) · 4.24 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Docs
on:
push:
branches: [main]
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'flixopt/**'
pull_request:
paths:
- 'docs/**'
- 'mkdocs.yml'
workflow_dispatch:
workflow_call:
inputs:
deploy:
type: boolean
default: false
version:
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
MPLBACKEND: Agg
PLOTLY_RENDERER: json
jobs:
build:
name: Build documentation
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.9.10"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
# Hash notebooks + flixopt source code (sorted for stable cache keys)
HASH=$(find docs/notebooks -name '*.ipynb' | sort | xargs cat | cat - <(find flixopt -name '*.py' | sort | xargs cat) | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v4
id: notebook-cache
with:
path: docs/notebooks/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute notebooks in parallel
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
# Execute all notebooks in parallel (4 at a time)
# Run from notebooks directory so relative imports work
cd docs/notebooks && find . -name '*.ipynb' -print0 | \
xargs -0 -P 4 -I {} jupyter execute --inplace {}
- name: Build docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: mkdocs build --strict
- uses: actions/upload-artifact@v4
with:
name: docs
path: site/
retention-days: 7
deploy:
name: Deploy documentation
needs: build
if: ${{ inputs.deploy == true && inputs.version != '' }}
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@v7
with:
version: "0.9.10"
enable-cache: true
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Extract changelog
run: |
cp CHANGELOG.md docs/changelog.md
python scripts/format_changelog.py
- name: Install dependencies
run: uv pip install --system ".[docs,full]"
- name: Get notebook cache key
id: notebook-cache-key
run: |
# Hash notebooks + flixopt source code (sorted for stable cache keys)
HASH=$(find docs/notebooks -name '*.ipynb' | sort | xargs cat | cat - <(find flixopt -name '*.py' | sort | xargs cat) | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
- name: Cache executed notebooks
uses: actions/cache@v4
id: notebook-cache
with:
path: docs/notebooks/*.ipynb
key: notebooks-${{ steps.notebook-cache-key.outputs.hash }}
- name: Execute notebooks in parallel
if: steps.notebook-cache.outputs.cache-hit != 'true'
run: |
cd docs/notebooks && find . -name '*.ipynb' -print0 | \
xargs -0 -P 4 -I {} jupyter execute --inplace {}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Deploy docs
env:
MKDOCS_JUPYTER_EXECUTE: "false"
run: |
VERSION=${{ inputs.version }}
VERSION=${VERSION#v}
mike deploy --push --update-aliases $VERSION latest
mike set-default --push latest