From e08aad26d80db2cf344cad74cfd851a69a51d937 Mon Sep 17 00:00:00 2001
From: Muhammad Saud Khan <muhammadsaud.khan@cgi.com>
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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/publish-swagger-hub.yaml b/.github/workflows/publish-swagger-hub.yaml
index 7ef1e4137..736f8c4ab 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:
@@ -96,16 +96,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
+          if [[ $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