-
Notifications
You must be signed in to change notification settings - Fork 2
134 lines (121 loc) · 5.14 KB
/
generate-clients.yaml
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
name: Generate API Clients
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
generate:
runs-on: ubuntu-latest
if: success()
env:
# We only want to publish to client repositories when pushing on main branch
PUBLISH_CLIENTS: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
strategy:
matrix:
include:
- language: go
version: 6.0.1
target-branch: master
deploy-ssh-key: SSH_DEPLOY_KEY_GO
deploy-ssh-key-ws: SSH_DEPLOY_KEY_WS_GO
- language: javascript
version: 6.0.1
target-branch: main
deploy-ssh-key: SSH_DEPLOY_KEY_JAVASCRIPT
deploy-ssh-key-ws: SSH_DEPLOY_KEY_WS_JAVASCRIPT
- language: python
version: 6.0.1
target-branch: master
deploy-ssh-key: SSH_DEPLOY_KEY_PYTHON
deploy-ssh-key-ws: SSH_DEPLOY_KEY_WS_PYTHON
- language: typescript-axios
version: 5.3.1
target-branch: main
deploy-ssh-key: SSH_DEPLOY_KEY_TYPESCRIPT_AXIOS
deploy-ssh-key-ws: SSH_DEPLOY_KEY_WS_TYPESCRIPT_AXIOS
steps:
- name: Check out source code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.18"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Build OpenApi file
run: |
npm ci
npm run build
- name: Generate ${{ matrix.language }} client
uses: openapi-generators/openapitools-generator-action@v1
env:
GO_POST_PROCESS_FILE: "/usr/local/bin/gofmt -w"
with:
generator: ${{ matrix.language }}
generator-tag: v${{ matrix.version }}
openapi-file: _build/openapi.yaml
config-file: "generator/configs/${{ matrix.language }}.yaml"
command-args: |
-a bearer \
-o out/qovery-client-${{ matrix.language }} \
--enable-post-process-file \
--git-user-id qovery \
--git-repo-id qovery-client-${{ matrix.language }} \
--package-name qovery \
--additional-properties packageVersion=$(grep 'version' _build/openapi.yaml | head -1 | tr ':' '\n' | tail -1 | tr -d ' ') \
--additional-properties npmVersion=$(grep 'version' _build/openapi.yaml | head -1 | tr ':' '\n' | tail -1 | tr -d ' ')
- name: Generate ${{ matrix.language }} websocket client
uses: openapi-generators/openapitools-generator-action@v1
env:
GO_POST_PROCESS_FILE: "/usr/local/bin/gofmt -w"
with:
generator: ${{ matrix.language }}
generator-tag: v${{ matrix.version }}
openapi-file: websocket/websocket-openapi.yaml
config-file: "generator/configs/${{ matrix.language }}.yaml"
command-args: |
-a bearer \
-o out/qovery-client-ws-${{ matrix.language }} \
--enable-post-process-file \
--git-user-id qovery \
--git-repo-id qovery-client-ws-${{ matrix.language }} \
--package-name qovery \
--additional-properties packageVersion=$(grep 'version' websocket/websocket-openapi.yaml | head -1 | tr ':' '\n' | tail -1 | tr -d ' ') \
--additional-properties npmVersion=$(grep 'version' websocket/websocket-openapi.yaml | head -1 | tr ':' '\n' | tail -1 | tr -d ' ')
- name: Check post generation script existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "generator/post_generation_scripts/${{ matrix.language }}.sh"
- name: Run ${{ matrix.language }} post generation script
if: steps.check_files.outputs.files_exists == 'true'
run: generator/post_generation_scripts/${{ matrix.language }}.sh
- name: Publish ${{ matrix.language }} client
if: contains(env.PUBLISH_CLIENTS, 'true')
id: push_directory
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets[matrix.deploy-ssh-key] }}
with:
source-directory: out/qovery-client-${{ matrix.language }}
destination-github-username: "qovery"
destination-repository-name: "qovery-client-${{ matrix.language }}"
user-email: [email protected]
commit-message: See ORIGIN_COMMIT from $GITHUB_REF
target-branch: ${{ matrix.target-branch }}
- name: Publish ${{ matrix.language }} websocket client
if: contains(env.PUBLISH_CLIENTS, 'true')
id: push_directory_ws
uses: cpina/github-action-push-to-another-repository@main
env:
SSH_DEPLOY_KEY: ${{ secrets[matrix.deploy-ssh-key-ws] }}
with:
source-directory: out/qovery-client-ws-${{ matrix.language }}
destination-github-username: "qovery"
destination-repository-name: "qovery-client-ws-${{ matrix.language }}"
user-email: [email protected]
commit-message: See ORIGIN_COMMIT from $GITHUB_REF
target-branch: main