forked from eclipse-edc/IdentityHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: publish IdentityHub API to SwaggerHub (eclipse-edc#207)
* chore: publish IH API to SwaggerHub * fix api * DEPENDENCIES
- Loading branch information
1 parent
d3238c7
commit 858f28c
Showing
7 changed files
with
127 additions
and
37 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Publish OpenAPI Specs | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
version: | ||
required: true | ||
description: "The version under which the API should be published" | ||
type: string | ||
|
||
workflow_dispatch: | ||
inputs: | ||
version: | ||
required: true | ||
description: "The version under which the API should be published" | ||
type: string | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
Publish-To-SwaggerHub: | ||
# do NOT run on forks. The Org ("edc") is unique all across SwaggerHub | ||
# Disable temporarily, because we can only have 3 APIs in the SwaggerHub free tier | ||
if: github.repository == 'eclipse-edc/IdentityHub' && false | ||
runs-on: ubuntu-latest | ||
env: | ||
rootDir: resources/openapi/yaml | ||
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_TOKEN }} | ||
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }} | ||
VERSION: ${{ github.event.inputs.version || inputs.version }} | ||
API_NAME: 'ih-api' | ||
OUTPUT_FILE_NAME: 'ihapi.yaml' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup-build | ||
- uses: actions/setup-node@v4 | ||
|
||
# merge together all api groups | ||
- name: Generate API Specs | ||
run: | | ||
# give option to override | ||
cmd="" | ||
if [ ! -z $VERSION ]; then | ||
cmd="-Pversion=$VERSION" | ||
fi | ||
./gradlew resolve | ||
./gradlew ${cmd} -PapiTitle="IdentityHub REST API" -PapiDescription="REST API documentation for the IdentityHub" :mergeApiSpec --input=${{ env.rootDir }} --output=${{ env.OUTPUT_FILE_NAME }} | ||
# install swaggerhub CLI | ||
- name: Install SwaggerHub CLI | ||
run: npm i -g swaggerhub-cli | ||
|
||
# create API, will fail if exists | ||
- name: Create API | ||
continue-on-error: true | ||
run: | | ||
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/${{ env.API_NAME }} -f ${{ env.OUTPUT_FILE_NAME }} --visibility=public --published=unpublish | ||
# Post snapshots of the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten | ||
- name: Publish API Specs to SwaggerHub | ||
run: | | ||
# coalesce $VERSION, or whatever's stored in gradle.properties | ||
vers=${VERSION:-$(grep "version" gradle.properties | awk -F= '{print $2}')} | ||
if [[ $vers != *-SNAPSHOT ]]; then | ||
echo "no snapshot, will set the API to 'published'"; | ||
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/${{ env.API_NAME }} -f ${{ env.OUTPUT_FILE_NAME }} --visibility=public --published=publish | ||
swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/${{ env.API_NAME }}/$vers | ||
else | ||
echo "snapshot, will set the API to 'unpublished'"; | ||
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/${{ env.API_NAME }} -f ${{ env.OUTPUT_FILE_NAME }} --visibility=public --published=unpublish | ||
fi |
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
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
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
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
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
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