Skip to content

Commit

Permalink
docs: publish openapi-ui to github pages (#1425)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jul 17, 2024
1 parent 76b18db commit 1f40f32
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/publish-openapi-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#################################################################################
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
#################################################################################

---
name: "Publish OpenAPI to Swaggerhub"

on:
push:
branches:
- main
- release/*

workflow_dispatch:
inputs:
version:
required: false
description: "Version of the Tractus-X EDC API to be should be published"
type: string

jobs:
swagger-api:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java

- name: Set version
run: |
if [ -z ${{ inputs.version }} ]; then
export VERSION=$(grep "version" gradle.properties | awk -F= '{print $2}')
else
export VERSION=${{ inputs.version }}
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Generate openapi spec
shell: bash
run: |
./gradlew resolve
- name: Download upstream API specs for control-plane and data-plane
run: |
./gradlew :edc-controlplane:edc-controlplane-base:downloadOpenapi
cp edc-controlplane/edc-controlplane-base/build/docs/openapi/* resources/openapi/yaml/
./gradlew :edc-dataplane:edc-dataplane-base:downloadOpenapi
cp edc-dataplane/edc-dataplane-base/build/docs/openapi/* resources/openapi/yaml/
- name: Merge API specs
run: |
./gradlew -Pversion=${{ env.VERSION }} -PapiTitle="Tractus-X EDC REST API" -PapiDescription="Tractus-X EDC API Documentation" :mergeApiSpec --input=./resources/openapi/yaml --output=./resources/openapi/yaml/tractusx-edc-api.yaml
- name: Generate Swagger UI current version
uses: Legion2/swagger-ui-action@v1
with:
output: openapi/${{ env.VERSION }}
spec-file: resources/openapi/yaml/tractusx-edc-api.yaml

- name: Generate Swagger UI stable version
uses: Legion2/swagger-ui-action@v1
if: ${{ !endsWith( env.VERSION, '-SNAPSHOT') }}
with:
output: openapi
spec-file: resources/openapi/yaml/tractusx-edc-api.yaml

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: openapi
keep_files: true

0 comments on commit 1f40f32

Please sign in to comment.