Skip to content

Documentation

Documentation #17

Workflow file for this run

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