Skip to content

Commit

Permalink
chore(fix): resolved versioning issue to the swagger workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
saudkhan116 committed Apr 23, 2024
1 parent 3980aa7 commit 73ca7b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/publish-swagger-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ name: "Publish OpenAPI to Swaggerhub"

on:
push:
branches: [ "main", "develop" ]
branches: [ "main", "bugfix/fix-swagger-workflow" ]
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_call:
Expand All @@ -48,6 +48,7 @@ jobs:
env:
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }}
DOWNSTREAM_VERSION: ''

steps:
- uses: actions/checkout@v4
Expand All @@ -69,9 +70,9 @@ jobs:
run: |
if [ -z ${{ inputs.version }} ]; then
export DOWNSTREAM_VERSION=${{ steps.version.outputs.tag }}
DOWNSTREAM_VERSION=${{ steps.version.outputs.tag }}
else
export DOWNSTREAM_VERSION=${{ inputs.version }}
DOWNSTREAM_VERSION=${{ inputs.version }}
fi
echo "[INFO] - DOWNSTREAM_VERSION=$DOWNSTREAM_VERSION" >> "$GITHUB_ENV"
Expand All @@ -96,16 +97,16 @@ jobs:
- name: Create API
continue-on-error: true
run: |
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/digital-product-pass/${{ env.DOWNSTREAM_VERSION }} -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=unpublish
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/digital-product-pass/$DOWNSTREAM_VERSION -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=unpublish
# Post the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten
- name: Publish API Specs to SwaggerHub
run: |
if [[ ${{ env.DOWNSTREAM_VERSION }} != *-SNAPSHOT ]]; then
echo "[INFO] - no snapshot, will set the API to 'published'";
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/digital-product-pass/${{ env.DOWNSTREAM_VERSION }} -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=publish
swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/digital-product-pass/${{ env.DOWNSTREAM_VERSION }}
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/digital-product-pass/$DOWNSTREAM_VERSION -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=publish
swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/digital-product-pass/$DOWNSTREAM_VERSION
else
echo "[INFO] - snapshot, will set the API to 'unpublished'";
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/digital-product-pass/${{ env.DOWNSTREAM_VERSION }} -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=unpublish
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/digital-product-pass/$DOWNSTREAM_VERSION -f ./dpp-backend/digitalproductpass/tractusx-dpp-api.yaml --visibility=public --published=unpublish
fi

0 comments on commit 73ca7b4

Please sign in to comment.