name: Documentation
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: null
permissions:
contents: read
jobs:
docs-build:
name: Build Docs Site
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
outputs:
pages-enabled: ${{ steps.pages.outputs.enabled }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Install Node dependencies
run: npm install
- name: Generate Rust API docs
run: 'cargo doc --no-deps --document-private-items
rm -rf docs/public/api/rust
mkdir -p docs/public/api/rust
cp -r target/doc/* docs/public/api/rust/
'
- name: Generate TypeScript API docs
run: bash scripts/generate_ts_docs.sh
- name: Generate C# API docs
run: bash scripts/generate_cs_docs.sh
- name: Build VitePress site
run: npm run docs:build
- name: Detect GitHub Pages
id: pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
GH_TOKEN: ${{ github.token }}
run: |
status=$(curl -sS -o /tmp/pages.json -w "%{http_code}" \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pages")
case "${status}" in
200)
echo "enabled=true" >> "${GITHUB_OUTPUT}"
;;
404)
echo "enabled=false" >> "${GITHUB_OUTPUT}"
echo "GitHub Pages is not enabled for this repository; skipping docs deployment."
;;
*)
cat /tmp/pages.json
echo "Unexpected GitHub Pages API status: ${status}" >&2
exit 1
;;
esac
- name: Configure GitHub Pages
if: steps.pages.outputs.enabled == 'true'
uses: actions/configure-pages@v5
- name: Upload Pages artifact
if: steps.pages.outputs.enabled == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
timeout-minutes: 15
docs-deploy:
name: Deploy Docs Site
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.docs-build.outputs.pages-enabled == 'true'
needs: docs-build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
timeout-minutes: 15