Skip to content

Commit e434aad

Browse files
committed
feat: add docs preview workflow for PRs
Build MkDocs site on PRs that touch docs and deploy to Cloudflare Pages. Each PR gets a browseable preview URL posted as a comment. Notebook tutorials use placeholder stubs since they require API keys to execute. Requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repo secrets.
1 parent 6216dd9 commit e434aad

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

.github/workflows/docs-preview.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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-and-deploy:
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
78+
79+
- name: Deploy to Cloudflare Pages
80+
id: deploy
81+
uses: cloudflare/wrangler-action@v3
82+
with:
83+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
84+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
85+
command: pages deploy site/ --project-name=dd-docs-preview --branch=pr-${{ github.event.pull_request.number }}
86+
87+
- name: Find existing comment
88+
uses: peter-evans/find-comment@v4
89+
id: find-comment
90+
with:
91+
issue-number: ${{ github.event.pull_request.number }}
92+
comment-author: "github-actions[bot]"
93+
body-includes: "<!-- docs-preview -->"
94+
95+
- name: Post or update PR comment
96+
uses: peter-evans/create-or-update-comment@v5
97+
with:
98+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
99+
issue-number: ${{ github.event.pull_request.number }}
100+
edit-mode: replace
101+
body: |
102+
<!-- docs-preview -->
103+
**Docs preview:** ${{ steps.deploy.outputs.deployment-url }}
104+
105+
> Notebook tutorials are placeholder-only in previews.

0 commit comments

Comments
 (0)