-
Notifications
You must be signed in to change notification settings - Fork 16
87 lines (82 loc) · 3.33 KB
/
swagger.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
84
85
86
87
name: API Swagger Docs
on:
push:
branches:
- main
pull_request:
paths:
- 'api/**/*'
jobs:
api-swagger:
name: Generate vocdoni-api.yaml
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- name: Install swag
run: |
curl -L https://github.com/swaggo/swag/releases/download/v1.16.3/swag_1.16.3_Linux_amd64.tar.gz | tar -xzf -
- name: Run swag
run: ./swag init --parseDependency --parseDepth 1 --parseInternal --md api/docs/descriptions --overridesFile api/docs/.swaggo -g api.go -d api/,api/docs/models/ -o api/docs --ot yaml
- name: Install api-spec-converter
run: npm install -g api-spec-converter
- name: Convert the Swagger file to OAS3 format
run: api-spec-converter --from=swagger_2 --to=openapi_3 --syntax=yaml api/docs/swagger.yaml > api/docs/oas3.yaml
- name: yq - portable yaml processor
uses: mikefarah/[email protected]
with:
cmd: |
yq '.components.schemas."api.GenericTransactionWithInfo".properties.tx = load("api/docs/models/transactions.yaml").target' \
api/docs/oas3.yaml > api/docs/vocdoni-api.yaml
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: vocdoni-api.yaml
path: api/docs/vocdoni-api.yaml
developer-portal-pr:
name: Open PR to developer-portal repo
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: api-swagger
steps:
- name: Checkout developer-portal repo
uses: actions/checkout@v4
with:
repository: vocdoni/developer-portal
ref: main
- name: Remove old yaml
run: rm swaggers/vocdoni-api.yaml
- name: Pull new yaml
uses: actions/download-artifact@v4
with:
name: vocdoni-api.yaml
path: swaggers
- uses: benjlevesque/[email protected] # sets env.SHA to the first 7 chars of github.sha
- name: Create PR to developer-portal repo
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.VOCDONIBOT_PAT }}
commit-message: "Update vocdoni-api docs by commit ${{ env.SHA }}"
committer: "Arabot-1 <[email protected]>"
base: main
branch: update-api-docs
#branch-suffix: short-commit-hash ## creates temp update-sdk-docs-xyz branches
delete-branch: true ## true: delete branch after merging
title: Update docs with vocdoni-api repo changes
body: |
* This is an automated pull request to upload the updated vocdoni-api documentation.
* GitHub Action Run: [${{ github.run_id }}](https://github.com/vocdoni/vocdoni-node/actions/runs/${{ github.run_id }})
labels: |
automated pr
reviewers: ${{ github.actor }}
team-reviewers: SdkDocsReviewer
- name: "Check PR: ${{ steps.cpr.outputs.pull-request-url }}"
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"