Initial eMASS API specification v3.12 implementation (#14) #72
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |