-
Notifications
You must be signed in to change notification settings - Fork 17
103 lines (95 loc) · 4.04 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
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: benjlevesque/[email protected] # sets env.SHA to the first 7 chars of github.sha
- name: Checkout developer-portal repo
uses: actions/checkout@v4
with:
repository: vocdoni/developer-portal
ref: main
path: developer-portal
- uses: actions/setup-go@v5
with:
go-version: '1.23'
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 > developer-portal/swaggers/vocdoni-api.yaml
- name: Publish Artifact
uses: actions/upload-artifact@v4
with:
name: vocdoni-api.yaml
path: developer-portal/swaggers/vocdoni-api.yaml
- name: Check if there is a difference
uses: mathiasvr/[email protected]
id: diff
with:
run: git -C developer-portal diff --no-color swaggers/vocdoni-api.yaml
- name: Mark previous comment as outdated if no diff
if: ${{ github.event_name == 'pull_request' && steps.diff.outputs.stdout == '' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: diff
hide: true
hide_classify: "OUTDATED"
- name: Post comment with diff in original PR
if: ${{ github.event_name == 'pull_request' && steps.diff.outputs.stdout }}
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: diff
message: |
This PR introduces the following changes in the developer-portal documentation:
```diff
${{ steps.diff.outputs.stdout }}
```
- name: Create PR to developer-portal repo
id: cpr
uses: peter-evans/create-pull-request@v6
if: ${{ github.event_name == 'push' }}
with:
path: developer-portal
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 }}"