-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (69 loc) · 2.41 KB
/
docs.yml
File metadata and controls
78 lines (69 loc) · 2.41 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
name: Documentation
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to generate (leave empty to rebuild all tags)'
required: false
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup uv
uses: astral-sh/setup-uv@v4
- name: Determine versions to build
id: versions
run: |
site_exists=false
if git fetch origin site 2>/dev/null; then
site_exists=true
git worktree add site-branch origin/site
mkdir -p docs
cp -r site-branch/* docs/ 2>/dev/null || true
git worktree remove site-branch
fi
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "tags=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
elif [ "${{ github.ref_type }}" = "tag" ]; then
echo "tags=${{ github.ref_name }}" >> $GITHUB_OUTPUT
else
tags=$(git tag -l 'v*' --sort=-v:refname | tr '\n' ' ')
echo "tags=$tags" >> $GITHUB_OUTPUT
echo "Rebuilding all tags: $tags"
fi
- name: Generate documentation
run: |
mkdir -p docs
for tag in ${{ steps.versions.outputs.tags }}; do
echo "=== Generating docs for $tag ==="
git checkout "$tag" -- src/cyaml.h README.md refs/ypath/spec.md 2>/dev/null || true
uv run --with markdown python3 tools/gendocs.py "$tag"
git restore src/cyaml.h README.md refs/ypath/spec.md 2>/dev/null || true
done
- name: Push to site branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
tmp=$(mktemp -d)
cp -r docs/* "$tmp"
git reset --hard HEAD
git switch --orphan site-deploy
rm -rf *
cp -r "$tmp"/* .
git add -A
git commit -m "docs: update"
git push -f origin site-deploy:site
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy docs --project-name=cyaml --commit-dirty=true