Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 28 additions & 96 deletions .github/workflows/github-pages-mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,125 +18,57 @@
workflows: ['github-release']
types: [completed]

# Each job restores the .jupyter_cache/ content-addressed store from
# actions/cache and runs scripts/prep_notebooks.py to populate working-tree
# notebooks with outputs (executing only those missing from the cache), then
# hands off to the shared mkdocs-deploy composite action which builds with
# mkdocs-jupyter execute: false — reading the populated outputs directly.
#
# The cache key pins on all notebook inputs + library source + pyproject.toml.
# Any change to library code a notebook imports invalidates the cache and
# forces re-execution, keeping rendered outputs correct.
#
# The prep step uses the runner's default Python with a light pip install
# (statista + jupyter + nbconvert) — it does NOT install uv; the composite
# action does that itself for the mkdocs build.

jobs:
deploy-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Restore jupyter notebook cache
uses: actions/cache@v4
with:
path: .jupyter_cache
key: jupyter-cache-${{ hashFiles('docs/notebook/**/*.ipynb', 'src/statista/**/*.py', 'pyproject.toml') }}
restore-keys: |
jupyter-cache-

- name: Prepare notebook outputs (execute uncached, merge cached)
run: |
pip install -e . jupyter nbconvert ipykernel
python scripts/prep_notebooks.py

- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
with:
trigger: 'pull_request'
package-manager: 'uv'
python-version: '3.12'
install-groups: 'groups: docs'
deploy-token: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
notebooks-path: 'docs/notebook'

deploy-main:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Restore jupyter notebook cache
uses: actions/cache@v4
with:
path: .jupyter_cache
key: jupyter-cache-${{ hashFiles('docs/notebook/**/*.ipynb', 'src/statista/**/*.py', 'pyproject.toml') }}
restore-keys: |
jupyter-cache-

- name: Prepare notebook outputs (execute uncached, merge cached)
run: |
pip install -e . jupyter nbconvert ipykernel
python scripts/prep_notebooks.py
- uses: actions/checkout@v5
with:
fetch-depth: 0

- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
with:
trigger: 'main'
package-manager: 'uv'
python-version: '3.12'
install-groups: 'groups: docs'
deploy-token: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
with:
trigger: 'main'
package-manager: 'uv'
python-version: '3.12'
install-groups: 'groups: docs'
deploy-token: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
notebooks-path: 'docs/notebook'

deploy-release:
if: github.event_name == 'release' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
steps:
# When triggered by workflow_run, GitHub loads this workflow file from the
# default branch but the checkout would default to that branch's HEAD too.
# We instead pin checkout to the branch where `github-release` actually ran
# (e.g. release/0.8.0) so the docs build sees the version-bump + lockfile
# commits and tag that github-release just pushed onto that branch.
# (Don't use head_sha here — that's the pre-bump SHA that triggered
# github-release, not the post-bump HEAD we want to publish.)
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || '' }}

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Restore jupyter notebook cache
uses: actions/cache@v4
with:
path: .jupyter_cache
key: jupyter-cache-${{ hashFiles('docs/notebook/**/*.ipynb', 'src/statista/**/*.py', 'pyproject.toml') }}
restore-keys: |
jupyter-cache-

- name: Prepare notebook outputs (execute uncached, merge cached)
run: |
pip install -e . jupyter nbconvert ipykernel
python scripts/prep_notebooks.py
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || '' }}

- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
with:
trigger: 'release'
package-manager: 'uv'
python-version: '3.12'
install-groups: 'groups: docs'
deploy-token: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
mike-alias: 'latest'
- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1

Check failure

Code scanning / CodeQL

Checkout of untrusted code in a privileged context High

Checkout of untrusted code in a privileged workflow with later potential execution (event trigger:
workflow_run
).
with:
trigger: 'release'
package-manager: 'uv'
python-version: '3.12'
install-groups: 'groups: docs'
deploy-token: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
notebooks-path: 'docs/notebook'
mike-alias: 'latest'
4 changes: 0 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ theme:
plugins:
- search
- mkdocs-jupyter:
# Committed notebooks have outputs stripped (nbstripout pre-commit hook);
# CI populates outputs via scripts/prep_notebooks.py before the build,
# using a GitHub Actions cache keyed on notebook + source + pyproject hash.
# See .github/workflows/github-pages-mkdocs.yml.
execute: false
allow_errors: false
- autorefs
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ docs = [
"notebook<7.0",
"jupyter",
"commitizen (>=4.8.3,<5.0.0)",
"nbconvert",
"ipykernel"
]


Expand Down
90 changes: 0 additions & 90 deletions scripts/prep_notebooks.py

This file was deleted.

6 changes: 5 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading