-
Notifications
You must be signed in to change notification settings - Fork 896
77 lines (67 loc) · 2.27 KB
/
schema-markdown-config.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
name: Generate config reference markdown
run-name: Generate config reference markdown for ${{ github.ref_name }}
on:
push:
tags:
- 'backend/*'
workflow_dispatch:
jobs:
config:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/setup-node@v4
with:
node-version: '20.16.0'
registry-url: https://registry.npmjs.org/
- name: Checkout backend
uses: actions/checkout@v4
with:
path: hanko
- name: Checkout backend wiki
uses: actions/checkout@v4
with:
repository: ${{github.repository}}.wiki
path: wiki
- name: Generate config markdown
working-directory: ./hanko/backend
run: |
go generate ./...
go run main.go schema markdown config
- name: Strip links of .md file endings
working-directory: ./hanko/backend
run: |
find ./.generated/docs/config -type f -name "*.md" -exec sed -i "s/\.md//g" "{}" \;
- name: Prepend version information
working-directory: ./hanko/backend
run: |
version=$(echo $GITHUB_REF_NAME | cut -f2 -d'/')
find ./.generated/docs/config -type f -name '*.md' -exec sed -i "1i\\
## Version\\
\\
\`$version\`\\
\\
" {} \;
- name: Copy generated files
working-directory: ./hanko/backend
run: |
mkdir -p $GITHUB_WORKSPACE/wiki/reference/config
rm $GITHUB_WORKSPACE/wiki/reference/config/*.md 2>/dev/null || true
cp .generated/docs/config/*.md $GITHUB_WORKSPACE/wiki/reference/config
- name: Commit and push to wiki
working-directory: ./wiki
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
if ! git diff-index --quiet HEAD; then
version=$(echo $GITHUB_REF_NAME | cut -f2 -d'/')
git commit -m "chore: autogenerate config reference for $version"
git pull origin master --rebase
git push origin HEAD
else
echo "No changes detected, skipping commit and push."
fi