Skip to content

Fix github action

Fix github action #808

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 }}-ws.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-ws \
--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: Check post websocket generation script existence
id: check_files_ws
uses: andstor/file-existence-action@v1
with:
files: "generator/post_generation_scripts/${{ matrix.language }}-ws.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: Run ${{ matrix.language }} websocket post generation script
if: steps.check_files.outputs.files_exists == 'true'
run: generator/post_generation_scripts/${{ matrix.language }}-ws.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