-
Notifications
You must be signed in to change notification settings - Fork 2
89 lines (77 loc) · 3.8 KB
/
generate-clients.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
name: Generate OpenAPI Clients
# For testing use the PR name for 'branches:' - once done testing revert the 'branches:' name to main
on:
push:
branches: [ main ]
# pull_request:
# branches: [ main ]
jobs:
generate-eMASS-clients:
runs-on: ubuntu-latest
name: Generate OpenAPI Clients
steps:
# Checkout your code
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
# Check for changed files (looking for changes to the docs/eMASSRestOpenApi.yaml file)
- name: Get changed file (eMASSRestOpenApi.yaml) 🔧
id: changed-files
uses: tj-actions/changed-files@v39
- name: Run a step if eMASSRestOpenApi.yaml was modified
if: contains(steps.changed-files.outputs.modified_files, 'eMASSRestOpenApi.yaml')
run: |
echo "eMASSRestOpenApi.yaml file has been modified."
# Use the action to generate a client package
# This uses the default path for the openapi document and thus assumes there is an openapi.json in the current workspace.
- name: Generate Ruby Client 🏭
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: ruby
config-file: src/openapi/templates/ruby/ruby-generator-config.json
template-dir: src/openapi/templates/ruby
openapi-file: docs/eMASSRestOpenApi.yaml
if: contains(steps.changed-files.outputs.modified_files, 'eMASSRestOpenApi.yaml')
- name: Generate Typescript Client 🏭
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: typescript-axios
config-file: src/openapi/templates/typescript/typescript-generator-config.json
template-dir: src/openapi/templates/typescript
openapi-file: docs/eMASSRestOpenApi.yaml
if: contains(steps.changed-files.outputs.modified_files, 'eMASSRestOpenApi.yaml')
- name: Generate Python Client 🏭
uses: openapi-generators/openapitools-generator-action@v1
with:
generator: python
config-file: src/openapi/templates/python/python-generator-config.json
template-dir: src/openapi/templates/python/mustache
openapi-file: docs/eMASSRestOpenApi.yaml
if: contains(steps.changed-files.outputs.modified_files, 'eMASSRestOpenApi.yaml')
# Publish the newly generated eMASS client to the current repo
- name: Publish Generated Clients to GitHub 🚀
if: contains(steps.changed-files.outputs.modified_files, 'eMASSRestOpenApi.yaml')
env:
CI_COMMIT_MESSAGE: CI Build Client Artifacts (eMASS Clients)
CI_COMMIT_AUTHOR: CI Pipeline
# Use previous user who made the last commit (from logs)
# CI_COMMIT_AUTHOR: "$(git log -n 1 --pretty=format:%an)"
CI_COMMIT_EMAIL: "$(git log -n 1 --pretty=format:%ae)"
run: |
# echo "Renaming generated directory from ruby-client to ruby_client..."
rm -R src/ruby_client
mv ruby-client src/ruby_client
# echo "Renaming generated directory from typescript-axios-client to typescript_client..."
rm -R src/typescript_client
mv typescript-axios-client src/typescript_client
# echo "Renaming generated directory from python-client to python_client..."
rm -R src/python_client
mv python-client src/python_client
# echo "GIT commit and push eMASS clients..."
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
git add src/ruby_client src/typescript_client src/python_client
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
git push -f
echo "All done now."