Skip to content

Generate Docs

Generate Docs #63

Workflow file for this run

name: Generate Docs
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
paths:
- .github/workflows/generate-docs.yml
permissions:
contents: write
pull-requests: write
jobs:
discover:
name: Discover Repos
runs-on: ubuntu-latest
outputs:
repos: ${{ steps.find.outputs.repos }}
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Find repos
id: find
run: |
set -euo pipefail
ORG="${GITHUB_REPOSITORY_OWNER,,}"
repos=$(
gh api --paginate "/orgs/${ORG}/repos" \
--jq '[.[] | select(
.archived == false and
.disabled == false and
(.name | ascii_downcase | IN("bluelua.github.io", ".github") | not)
) | .name]'
)
echo "repos=${repos}" >> "${GITHUB_OUTPUT}"
generate:
name: Generate ${{ matrix.repo }} Docs
needs: discover
if: ${{ needs.discover.outputs.repos != '[]' }}
runs-on: ubuntu-latest
strategy:
matrix:
repo: ${{ fromJson(needs.discover.outputs.repos) }}
fail-fast: false
steps:
- name: Checkout central docs repo
uses: actions/checkout@v7
- name: Checkout target repo
uses: actions/checkout@v7
with:
repository: ${{ github.repository_owner }}/${{ matrix.repo }}
path: _repo
- name: Setup LuaJIT
uses: leafo/gh-actions-lua@v13
with:
luaVersion: "luajit"
- name: Generate docs
run: |
target="docs/src/${{ matrix.repo }}"
rm -rf "${target}"
mkdir -p "${target}"
if [ -f "_repo/README.md" ]; then
cp "_repo/README.md" "${target}/index.md"
fi
if [ -d "_repo/types" ]; then
luajit scripts/generate-docs.lua "_repo/types" "${target}"
fi
if [ -d "_repo/tutorials" ]; then
cp -R _repo/tutorials "${target}/"
fi
- name: Format docs
run: npx --yes prettier@latest --write "docs/src/${{ matrix.repo }}/**/*.md" --no-error-on-unmatched-pattern
- name: Open docs PR
uses: peter-evans/create-pull-request@v8
with:
commit-message: "docs: generate docs for ${{ matrix.repo }}"
title: "docs: generate docs for ${{ matrix.repo }}"
branch: "automation/generate-docs-${{ matrix.repo }}"
add-paths: docs/src/${{ matrix.repo }}