Skip to content

Commit ed682ad

Browse files
committed
feat: add docs preview workflow for PRs
Build MkDocs site on PRs that touch docs, upload as artifact, and comment a download link. Notebook tutorials use placeholder stubs since they require API keys to execute.
1 parent 6216dd9 commit ed682ad

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

.github/workflows/docs-preview.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Docs preview
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "docs/**"
8+
- "mkdocs.yml"
9+
- "packages/*/src/data_designer/**"
10+
- ".github/workflows/docs-preview.yml"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v6
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
24+
with:
25+
version: "0.9.5"
26+
27+
- name: Set up Python
28+
run: uv python install 3.11
29+
30+
- name: Install docs dependencies
31+
run: uv sync --all-packages --group docs
32+
33+
- name: Create notebook stubs
34+
run: |
35+
mkdir -p docs/notebooks
36+
cp docs/notebook_source/_README.md docs/notebooks/README.md
37+
38+
for src in docs/notebook_source/*.py; do
39+
name=$(basename "$src" .py)
40+
cat > "docs/notebooks/${name}.ipynb" <<'STUB'
41+
{
42+
"cells": [
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"# Notebook preview not available\n",
48+
"\n",
49+
"Tutorial notebooks are built during the release process and are not\n",
50+
"included in PR previews. Run the notebook locally with:\n",
51+
"\n",
52+
"```bash\n",
53+
"make convert-execute-notebooks\n",
54+
"make serve-docs-locally\n",
55+
"```"
56+
]
57+
}
58+
],
59+
"metadata": {
60+
"kernelspec": {
61+
"display_name": "Python 3",
62+
"language": "python",
63+
"name": "python3"
64+
},
65+
"language_info": {
66+
"name": "python",
67+
"version": "3.11.0"
68+
}
69+
},
70+
"nbformat": 4,
71+
"nbformat_minor": 5
72+
}
73+
STUB
74+
done
75+
76+
- name: Build docs
77+
run: uv run mkdocs build --strict
78+
79+
- name: Upload docs artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: docs-preview
83+
path: site/
84+
retention-days: 7
85+
86+
- name: Find existing comment
87+
uses: peter-evans/find-comment@v3
88+
id: find-comment
89+
with:
90+
issue-number: ${{ github.event.pull_request.number }}
91+
comment-author: "github-actions[bot]"
92+
body-includes: "<!-- docs-preview -->"
93+
94+
- name: Post or update PR comment
95+
uses: peter-evans/create-or-update-comment@v4
96+
with:
97+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
98+
issue-number: ${{ github.event.pull_request.number }}
99+
edit-mode: replace
100+
body: |
101+
<!-- docs-preview -->
102+
**Docs preview built successfully** - [Download artifact](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
103+
104+
To view locally:
105+
```bash
106+
unzip docs-preview.zip -d docs-preview
107+
cd docs-preview
108+
python -m http.server 8000
109+
# open http://localhost:8000
110+
```
111+
112+
> Notebook tutorials are placeholder-only in previews.

0 commit comments

Comments
 (0)