Skip to content

Upgrade cosmotech-api-common version to 1.0.4 #2802

Upgrade cosmotech-api-common version to 1.0.4

Upgrade cosmotech-api-common version to 1.0.4 #2802

Workflow file for this run

name: OpenAPI
on:
workflow_dispatch:
push:
branches:
- main
tags:
- '*'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- 'main'
- 'release/**'
jobs:
validate_projects_openapis:
# The OpenAPI Generator Gradle Plugin exposes an 'openApiValidate' task,
# but at this time, it does not work with Gradle 7.0.
# See https://github.com/OpenAPITools/openapi-generator/issues/9328
# This job is a different approach for validation, using the Swagger Editor service,
# as suggested here : https://swagger.io/blog/api-design/validate-openapi-definitions-swagger-editor/
runs-on: ubuntu-latest
name: OpenAPI Validator Service
services:
swagger-editor:
image: swaggerapi/swagger-editor:v3.16.5
ports:
- 80:8080
strategy:
fail-fast: false
matrix:
project:
- connector
- dataset
- organization
- scenario
- scenariorun
- solution
- workspace
- twingraph
steps:
- uses: actions/checkout@v4
- name: Validate '${{ matrix.project }}' definition
uses: char0n/swagger-editor-validate@v1.3.2
with:
swagger-editor-url: http://localhost/
definition-file: ${{ matrix.project }}/src/main/openapi/${{ matrix.project }}.yaml
merge_openapi_specs:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
# Fetch all tags since Gradle project version is built upon SCM
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Merge OpenAPI definitions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: gradle/gradle-build-action@v3
with:
cache-disabled: false
# Cache storage space is limited for GitHub actions
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: mergeOpenApiFiles
- name: Archive openapi.yaml
uses: actions/upload-artifact@v3
with:
name: openapi
path: openapi/openapi.yaml
retention-days: 3
validate_merged_openapi:
# The OpenAPI Generator Gradle Plugin exposes an 'openApiValidate' task,
# but at this time, it does not work with Gradle 7.0.
# See https://github.com/OpenAPITools/openapi-generator/issues/9328
# This job is a different approach for validation, using the Swagger Editor service,
# as suggested here : https://swagger.io/blog/api-design/validate-openapi-definitions-swagger-editor/
runs-on: ubuntu-latest
needs: merge_openapi_specs
services:
swagger-editor:
image: swaggerapi/swagger-editor:v3.18.2
ports:
- 80:8080
steps:
- uses: actions/checkout@v4
- name: Download openapi artifact
uses: actions/download-artifact@v3
with:
name: openapi
- name: Validate merged OpenAPI definition
uses: char0n/swagger-editor-validate@v1.3.2
with:
swagger-editor-url: http://localhost/
definition-file: openapi.yaml
upload_merged_openapi:
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
needs: validate_merged_openapi
concurrency:
group: openapi-upload_${{ github.ref }}
cancel-in-progress: false
steps:
- name: Retrieve branch or tag name
id: refvar
run: echo "::set-output name=gitRefName::${GITHUB_REF#refs/*/}"
- name: Download openapi artifact
uses: actions/download-artifact@v3
with:
name: openapi
- name: azure login
uses: azure/login@v1.4.3
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload tagged openapi.yml to Azure Storage
if: startsWith(github.ref, 'refs/tags/')
run: |
az storage blob upload \
--account-name csmphoenixdev \
--container-name public \
--name openapi-${{ steps.refvar.outputs.gitRefName }}.yaml \
--overwrite \
--file openapi.yaml
- name: Upload openapi.yml to Azure Storage
if: github.ref == 'refs/heads/main'
run: |
az storage blob upload \
--account-name csmphoenixdev \
--container-name public \
--name openapi.yaml \
--overwrite \
--file openapi.yaml