-
Notifications
You must be signed in to change notification settings - Fork 3
82 lines (70 loc) · 3.02 KB
/
generate-docs.yml
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
name: generate docs for jsonschema
on:
workflow_dispatch:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
generate-docs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
# Setup node for jsonschema to markdown
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Generate resource schema doc
run: |
cp ./docs/reference/blocks.md /tmp/blocks.md
cp ./docs/reference/connection_types.md /tmp/connection_types.md
rm -rf ./docs/reference
mkdir ./docs/reference
nav_order=1
for schema in ./core/src/datayoga_core/resources/schemas/*.schema.json
do
npx jsonschema2mk --schema ${schema} --extension yaml-examples \
--extension front-matter --fm.parent "Reference" --fm.nav_order "${nav_order}" > \
./docs/reference/$(basename "${schema}" .schema.json).md \
nav_order=$((nav_order+1))
done
cp /tmp/blocks.md ./docs/reference/blocks.md
cp /tmp/connection_types.md ./docs/reference/connection_types.md
- name: Generate connection type schema docs
run: |
rm -rf ./docs/reference/connection_types
mkdir ./docs/reference/connection_types
for schema in ./core/src/datayoga_core/resources/schemas/connections/*.schema.json
do
npx jsonschema2mk --schema ${schema} --extension yaml-examples \
--extension front-matter --fm.parent "Connection Types" --fm.grand_parent "Reference" > \
./docs/reference/connection_types/$(basename "${schema}" .schema.json).md
done
- name: Generate block schema docs
run: |
rm -rf ./docs/reference/blocks
mkdir ./docs/reference/blocks
blocks_dir="./core/src/datayoga_core/blocks"
for schema in $(find ${blocks_dir} -name '*.schema.json')
do
doc_name="$(awk -F/ '{ print $(NF-1) }' <<<${schema}).md"
dir="$(echo ${schema} | sed -e s@${blocks_dir}@@)"
block_package="$(dirname $(dirname ${dir}))"
block_package="$(echo ${block_package} | cut -c2- | sed 's/\//_/g')"
[ ! -z "${block_package}" ] && block_package="${block_package}_"
npx jsonschema2mk --schema ${schema} --extension yaml-examples \
--extension front-matter --fm.parent "Blocks" --fm.grand_parent "Reference" > \
"./docs/reference/blocks/${block_package}${doc_name}"
done
- name: Push to repo
run: |
git config user.name github-actions
git config user.email [email protected]
git pull
git add .
git diff --cached --exit-code || git commit -m "update autogenerated docs"
git push