-
Notifications
You must be signed in to change notification settings - Fork 136
104 lines (92 loc) · 3.08 KB
/
docs-preview.yml
File metadata and controls
104 lines (92 loc) · 3.08 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
name: Docs preview
on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- "docs/**"
- "mkdocs.yml"
- ".github/workflows/docs-preview.yml"
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.9.5"
- name: Set up Python
run: uv python install 3.11
- name: Install docs dependencies
run: uv sync --all-packages --group docs
- name: Create notebook stubs
run: |
mkdir -p docs/notebooks
cp docs/notebook_source/_README.md docs/notebooks/README.md
for src in docs/notebook_source/*.py; do
name=$(basename "$src" .py)
cat > "docs/notebooks/${name}.ipynb" <<'STUB'
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Notebook preview not available\n",
"\n",
"Tutorial notebooks are built during the release process and are not\n",
"included in PR previews. Run the notebook locally with:\n",
"\n",
"```bash\n",
"make convert-execute-notebooks\n",
"make serve-docs-locally\n",
"```"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.11.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
STUB
done
- name: Build docs
run: uv run mkdocs build
- name: Deploy to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy site/ --project-name=dd-docs-preview --branch=pr-${{ github.event.pull_request.number }}
- name: Find existing comment
uses: peter-evans/find-comment@v4
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "<!-- docs-preview -->"
- name: Post or update PR comment
uses: peter-evans/create-or-update-comment@v5
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
<!-- docs-preview -->
**Docs preview:** ${{ steps.deploy.outputs.deployment-url }}
> Notebook tutorials are placeholder-only in previews.