-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (80 loc) · 2.46 KB
/
Copy pathgenerate-docs.yml
File metadata and controls
90 lines (80 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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 }}