Skip to content

Update API Documentation #181

Update API Documentation

Update API Documentation #181

Workflow file for this run

name: Update API Documentation
on:
schedule:
- cron: '0 0 * * *' # Run daily at midnight
workflow_dispatch: # Allow manual triggers
jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Fetch latest schema
run: npm run fetch-schema
- name: Check for changes in schema
id: check-changes
run: |
if git diff --quiet schema.graphql; then
echo "No changes detected in schema"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in schema"
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi
- name: Build site
if: steps.check-changes.outputs.changes_detected == 'true'
run: npm run build # fetch-schema + magidoc generate + clean-urls
- name: Commit and push changes
if: steps.check-changes.outputs.changes_detected == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# public/ is gitignored build output (regenerated on deploy), so
# `git add public/` fails with "paths are ignored" and, under
# `bash -e`, kills the step. Commit only the tracked schema, and
# skip the commit when nothing is staged so an unchanged schema
# doesn't error on "nothing to commit".
git add schema.graphql
git diff --staged --quiet || git commit -m "Update API documentation based on schema changes"
git push