From cf991b19903add59988f9dde0426aa8a6a09c4df Mon Sep 17 00:00:00 2001 From: Muhammad Saud Khan Date: Tue, 23 Apr 2024 15:26:38 +0200 Subject: [PATCH] chore(fix): resolved versioning issue to the swagger workflow --- .github/workflows/publish-swagger-hub.yaml | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish-swagger-hub.yaml b/.github/workflows/publish-swagger-hub.yaml index 7ef1e4137..e5fd015eb 100644 --- a/.github/workflows/publish-swagger-hub.yaml +++ b/.github/workflows/publish-swagger-hub.yaml @@ -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: @@ -69,11 +69,11 @@ jobs: run: | if [ -z ${{ inputs.version }} ]; then - export DOWNSTREAM_VERSION=${{ steps.version.outputs.tag }} + DOWNSTREAM_VERSION=${{ steps.version.outputs.tag }} >> "$GITHUB_ENV" else - export DOWNSTREAM_VERSION=${{ inputs.version }} + DOWNSTREAM_VERSION=${{ inputs.version }} >> "$GITHUB_ENV" fi - echo "[INFO] - DOWNSTREAM_VERSION=$DOWNSTREAM_VERSION" >> "$GITHUB_ENV" + echo $DOWNSTREAM_VERSION - name: Create and Download API specs shell: bash @@ -96,16 +96,5 @@ 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 - - # 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 }} - 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 - fi + echo $DOWNSTREAM_VERSION + swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/digital-product-pass/$DOWNSTREAM_VERSION