-
Notifications
You must be signed in to change notification settings - Fork 21
83 lines (71 loc) · 2.4 KB
/
swagger_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
83
name: Generate Endpoint Docs
on:
push:
branches:
- "main"
paths:
- "controllers/*.go"
- "cmd/backend.go"
- "docs/redocly.yaml"
- ".github/workflows/swagger_docs.yml"
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.KS_PAT }}
ref: docs
- name: Configure SSH key
env:
SSH_PRIVATE_KEY: ${{ secrets.KS_SSH_PRIVATE_KEY }}
SSH_PUBLIC_KEY: ${{ secrets.KS_SSH_PUBLIC_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/koss-service
echo "$SSH_PUBLIC_KEY" > ~/.ssh/koss-service.pub
chmod 600 ~/.ssh/koss-service
chmod 600 ~/.ssh/koss-service.pub
- name: Setup go
uses: actions/setup-go@v4
- name: install swag
run: go install github.com/swaggo/swag/cmd/swag@latest
- name: Setup node
uses: actions/setup-node@v3
- name: Merge the changes from main branch to docs branch
run: |
git config user.email "admin@kossiitkgp.org"
git config user.name "koss-service"
git config gpg.format ssh
git config user.signingkey ~/.ssh/koss-service.pub
git checkout -b docs || git checkout docs
git pull -S origin docs
git merge -S 'origin/${{ github.ref_name }}'
- name: Generate swagger.yaml and exit if no changes
run: |
go mod download
go mod tidy
swag init --parseDependency --parseInternal -g cmd/backend.go --ot yaml
- name: Generate the html doc
run: |
mkdir -p docs
pushd ./docs
npx @redocly/cli build-docs --output index.html --config redocly.yaml
popd
- name: Commit and push changes
run: |
cd ./docs || exit 1
git config user.email "admin@kossiitkgp.org"
git config user.name "koss-service"
git config gpg.format ssh
git config user.signingkey ~/.ssh/koss-service.pub
if [ -n "$(git status --porcelain swagger.yaml index.html)" ]; then
git add swagger.yaml index.html
git commit -S -m "Updated endpoints documentation"
git push
else
echo "No changes endpoint documentation"
fi