Skip to content

Commit

Permalink
build: add missing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Oct 1, 2024
1 parent 9e6d480 commit acf08ff
Showing 1 changed file with 122 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/publish-openapi-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#################################################################################
# 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 ui

on:

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

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

jobs:
generate-openapi-spec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java

- name: Generate openapi spec
run: ./gradlew resolve
- uses: actions/upload-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml

generate-swagger-ui:
needs: generate-openapi-spec
runs-on: ubuntu-latest
strategy:
matrix:
apiGroup: [
{ name: "control-plane", folder: "edc-controlplane/edc-controlplane-base" },
{ name: "data-plane", folder: "edc-dataplane/edc-dataplane-base" }
]
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- uses: actions/download-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml

- 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: Download upstream API specs for ${{ matrix.apiGroup.name }}
run: |
./gradlew -p ${{ matrix.apiGroup.folder }} downloadOpenapi
cp ${{ matrix.apiGroup.folder }}/build/docs/openapi/* resources/openapi/yaml/${{ matrix.apiGroup.name }}
- name: Merge API specs
run: |
./gradlew -Pversion=${{ env.VERSION }} -PapiTitle="Tractus-X EDC ${{ matrix.apiGroup.name }} API" -PapiDescription="Tractus-X EDC ${{ matrix.apiGroup.name }} API Documentation" :mergeApiSpec --input=./resources/openapi/yaml/${{ matrix.apiGroup.name }} --output=./resources/openapi/yaml/${{ matrix.apiGroup.name }}.yaml
- name: Generate Swagger UI current version
uses: Legion2/swagger-ui-action@v1
with:
output: dist/${{ env.VERSION }}
spec-file: resources/openapi/yaml/${{ matrix.apiGroup.name }}.yaml

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

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.apiGroup.name }}-api
path: dist

deploy-swagger-ui:
needs: generate-swagger-ui
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
path: openapi
pattern: "*-api"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: .
keep_files: true

0 comments on commit acf08ff

Please sign in to comment.