Skip to content

Update API Documentation #121

Update API Documentation

Update API Documentation #121

Workflow file for this run

name: Update API Documentation
on:
schedule:
# Run nightly at 2 AM UTC
- cron: "0 2 * * *"
workflow_dispatch:
jobs:
docs:
name: Update API Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout react-router-api-docs
uses: actions/checkout@v4
with:
path: react-router-api-docs
ref: main
- name: Checkout react-router
uses: actions/checkout@v4
with:
repository: remix-run/react-router
path: react-router
ref: main
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
cache-dependency-path: react-router/pnpm-lock.yaml
- name: Install dependencies
working-directory: react-router
run: pnpm install --frozen-lockfile
- name: Generate documentation
id: generate
working-directory: react-router
run: |
pnpm run build
pnpm run docs:typedoc
if [ ! -d "public/dev" ]; then
echo "Error: Documentation not generated"
exit 1
fi
echo "react_router_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Copy documentation
run: |
rm -rf react-router-api-docs/v7/*
cp -r react-router/public/dev/* react-router-api-docs/v7/
- name: Commit and push changes
working-directory: react-router-api-docs
run: |
git add v7/
if [ -z "$(git status --porcelain)" ]; then
echo "No changes detected"
exit 0
fi
# Exit if only sitemap.xml changed, which means it was only timestamp updates
if [ "$(git diff --name-only --cached | wc -l)" -eq 1 ]; then
if [ "$(git diff --name-only --cached)" = "v7/sitemap.xml" ]; then
echo "Only sitemap.xml changed (timestamps), skipping commit"
exit 0
fi
fi
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Updated API documentation from react-router SHA ${{ steps.generate.outputs.react_router_sha }}"
git push
echo "Pushed docs changes https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"