Skip to content

Commit 888d21b

Browse files
committed
Add api-docs mirror publish workflow
1 parent ed24c8e commit 888d21b

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,36 @@ jobs:
7171
name: ${{ steps.tagger.outputs.tag }}
7272
body_path: release_notes.md
7373
files: ${{ steps.tagger.outputs.zip_name }}
74+
75+
- name: Publish API docs repo payload
76+
env:
77+
API_DOCS_TARGET_REPO: phlppschrr/processwire-api-docs
78+
API_DOCS_TARGET_BRANCH: main
79+
API_DOCS_REPO_TOKEN: ${{ secrets.API_DOCS_REPO_TOKEN }}
80+
shell: bash
81+
run: |
82+
if [ -z "$API_DOCS_REPO_TOKEN" ]; then
83+
echo "Missing required secret: API_DOCS_REPO_TOKEN" >&2
84+
exit 1
85+
fi
86+
87+
export_dir="$(mktemp -d)"
88+
scripts/build_api_docs_repo.sh "$export_dir"
89+
90+
repo_dir="$(mktemp -d)"
91+
git clone "https://x-access-token:${API_DOCS_REPO_TOKEN}@github.com/${API_DOCS_TARGET_REPO}.git" "$repo_dir"
92+
93+
find "$repo_dir" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
94+
cp -R "$export_dir/." "$repo_dir/"
95+
96+
cd "$repo_dir"
97+
git config user.name "github-actions[bot]"
98+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
99+
git add -A
100+
if git diff --cached --quiet; then
101+
echo "No API docs changes to publish."
102+
exit 0
103+
fi
104+
105+
git commit -m "Publish API docs ${{ steps.tagger.outputs.tag }}"
106+
git push origin "HEAD:${API_DOCS_TARGET_BRANCH}"

scripts/build_api_docs_repo.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
usage() {
5+
cat <<'EOF'
6+
Usage:
7+
scripts/build_api_docs_repo.sh <output_dir>
8+
9+
Builds the standalone api-docs repository payload with this layout:
10+
api-docs/ (from docs/api-full)
11+
_processwire_version.json
12+
LICENSE
13+
NOTICE
14+
README.md
15+
context7.json
16+
EOF
17+
}
18+
19+
if [[ $# -ne 1 ]]; then
20+
usage
21+
exit 1
22+
fi
23+
24+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
25+
out_dir="$1"
26+
27+
mkdir -p "$out_dir"
28+
mkdir -p "$out_dir/api-docs"
29+
30+
if [[ ! -d "$repo_root/docs/api-full" ]]; then
31+
echo "Error: $repo_root/docs/api-full not found" >&2
32+
exit 1
33+
fi
34+
35+
if [[ ! -f "$repo_root/docs/_processwire_version.json" ]]; then
36+
echo "Error: $repo_root/docs/_processwire_version.json not found" >&2
37+
exit 1
38+
fi
39+
40+
find "$out_dir" -mindepth 1 -maxdepth 1 -exec rm -rf {} +
41+
mkdir -p "$out_dir/api-docs"
42+
43+
cp -R "$repo_root/docs/api-full/." "$out_dir/api-docs/"
44+
cp "$repo_root/docs/_processwire_version.json" "$out_dir/_processwire_version.json"
45+
cp "$repo_root/LICENSE" "$out_dir/LICENSE"
46+
cp "$repo_root/NOTICE.md" "$out_dir/NOTICE"
47+
48+
cat > "$out_dir/README.md" <<'EOF'
49+
# ProcessWire API Docs (Unofficial)
50+
51+
Unofficial, auto-generated ProcessWire API documentation in an LLM-friendly Markdown format.
52+
53+
The docs are generated from ProcessWire source code API docs for the ProcessWire CMS/CMF.
54+
55+
## Layout
56+
57+
- `api-docs/`: Full generated API reference (from `docs/api-full`)
58+
- `_processwire_version.json`: Version and build metadata
59+
- `LICENSE`
60+
- `NOTICE`
61+
EOF
62+
63+
cat > "$out_dir/context7.json" <<'EOF'
64+
{
65+
"$schema": "https://context7.com/schema/context7.json",
66+
"projectTitle": "ProcessWire API Docs",
67+
"description": "Unofficial auto-generated ProcessWire API docs in LLM-friendly Markdown format.",
68+
"folders": [
69+
"api-docs"
70+
],
71+
"excludeFiles": [
72+
"LICENSE",
73+
"NOTICE",
74+
"_processwire_version.json"
75+
]
76+
}
77+
EOF

0 commit comments

Comments
 (0)