-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (156 loc) · 5.37 KB
/
api.yml
File metadata and controls
181 lines (156 loc) · 5.37 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Validate and generate API, trigger updates
on:
push:
branches: [main]
jobs:
prerequisites:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
validate:
needs: prerequisites
runs-on: ubuntu-latest
container:
image: openapitools/openapi-generator-cli
steps:
- uses: actions/checkout@v4
- name: Validate API
run: docker-entrypoint.sh validate -i openapi.yaml
generate:
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v4
- name: Generate Dart API clients (docker)
run: |
docker run --rm -v ${{ github.workspace }}:/local -u $(id -u):$(id -g) openapitools/openapi-generator-cli generate \
-i /local/openapi.yaml -g dart-dio \
-o /local/dart-dio-client --git-user-id OpenParkProject \
--git-repo-id OPP-common \
--additional-properties=pubName=opp_api_client
- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: Install dependencies & run build_runner
working-directory: dart-dio-client
run: |
sudo apt-get update && sudo apt-get install -y unzip
dart pub get
dart run build_runner build --delete-conflicting-outputs
- name: Generate Python API client (docker)
run: |
docker run --rm -v ${{ github.workspace }}:/local -u $(id -u):$(id -g) openapitools/openapi-generator-cli generate \
-i /local/openapi.yaml -g python \
-o /local/python-client --git-user-id OpenParkProject \
--git-repo-id OPP-common \
--additional-properties=pubName=opp_api_client
- name: Upload Dart artifacts
uses: actions/upload-artifact@v4
with:
name: dart-dio-client
path: dart-dio-client
if-no-files-found: error
- name: Upload Python artifacts
uses: actions/upload-artifact@v4
with:
name: python-client
path: python-client
if-no-files-found: error
push-generated-dart:
runs-on: ubuntu-latest
needs: generate
steps:
- uses: actions/checkout@v4
- name: Download Dart artifacts
uses: actions/download-artifact@v4
with:
name: dart-dio-client
- name: push dart-dio-client
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions Bot"
git checkout --orphan dart-dio-client
git add .
git commit -m "Update generated dart-dio-client" || exit 0
git push origin dart-dio-client -f
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
push-generated-python:
runs-on: ubuntu-latest
needs: generate
steps:
- uses: actions/checkout@v4
- name: Download Python artifacts
uses: actions/download-artifact@v4
with:
name: python-client
- name: push python-client
run: |
git config user.email "actions@github.com"
git config user.name "GitHub Actions Bot"
git checkout --orphan python-client
git add .
git commit -m "Update generated python-client" || exit 0
git push origin python-client -f
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
runs-on: ubuntu-latest
needs: generate
steps:
- uses: actions/checkout@v4
- name: Download Dart artifacts
uses: actions/download-artifact@v4
with:
name: dart-dio-client
path: dart-dio-client
- name: Download Python artifacts
uses: actions/download-artifact@v4
with:
name: python-client
path: python-client
- name: Compress artifacts
run: |
tar -czf dart-dio-client.tar.gz dart-dio-client
tar -czf python-client.tar.gz python-client
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="v$(date +'%Y.%m.%d.%H%M')"
gh release create $VERSION \
--title "API $VERSION" \
--notes "Automated API release generated from OpenAPI spec" \
dart-dio-client.tar.gz \
python-client.tar.gz
trigger-frontend:
runs-on: ubuntu-latest
needs: generate
steps:
- name: Trigger repository_dispatch in OPP-frontend
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: OpenParkProject/OPP-frontend
event-type: OPP-common-updated
trigger-backend:
runs-on: ubuntu-latest
needs: generate
steps:
- name: Trigger repository_dispatch in OPP-backend
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: OpenParkProject/OPP-backend
event-type: OPP-common-updated
trigger-auth:
runs-on: ubuntu-latest
needs: generate
steps:
- name: Trigger repository_dispatch in OPP-auth
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REPO_DISPATCH_TOKEN }}
repository: OpenParkProject/OPP-auth
event-type: OPP-common-updated