Skip to content

Feature/properties #208

Feature/properties

Feature/properties #208

Workflow file for this run

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: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | 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: |
set -eo pipefail
# 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 {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- 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: |
set -eo pipefail
# Hash notebooks + flixopt source code using null-delimited find for safety
HASH=$({ find docs/notebooks -name '*.ipynb' -print0; find flixopt -name '*.py' -print0; } | sort -z | xargs -0 tar -cf - 2>/dev/null | 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: |
set -eo pipefail
cd docs/notebooks && find . -name '*.ipynb' -print0 | \
xargs -0 -P 4 -I {} sh -c 'jupyter execute --inplace "$1" || exit 255' _ {}
- 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