Skip to content

Generate Docs

Generate Docs #16

Workflow file for this run

name: Generate Docs
on:
workflow_dispatch:
workflow_run:
workflows: ["CI"]
types: [completed]
branches: [main]
permissions:
contents: write
jobs:
generate:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check for relevant changes
id: changes
run: |
CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -E '^(lib/|docs/playground/)' | grep -v 'docs/playground/public/' | grep -v 'docs/reference/' || true)
if [ -z "$CHANGED" ]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "No relevant changes, skipping generation"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "Changed files:"
echo "$CHANGED"
fi
- uses: ruby/setup-ruby@v1
if: steps.changes.outputs.skip != 'true'
with:
ruby-version: '3.2'
bundler-cache: true
working-directory: docs/playground
- name: Cache YARD
if: steps.changes.outputs.skip != 'true'
uses: actions/cache@v4
with:
path: .yardoc
key: yard-${{ hashFiles('lib/**/*.rb') }}
- name: Generate docs
if: steps.changes.outputs.skip != 'true'
env:
RAILS_ENV: test
run: |
cd docs/playground
bundle exec rake db:setup
bundle exec rake apiwork:docs:reference
bundle exec rake docs:generate
- name: Commit and push
if: steps.changes.outputs.skip != 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/reference/ docs/playground/public/ docs/examples/
git diff --staged --quiet || git commit -m "chore: regenerate docs"
git push