Skip to content

Commit

Permalink
add job to delete published APIs on swaggerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
swaroopar committed Apr 17, 2024
1 parent 0ab12f3 commit 7a6ac91
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/delete-api-on-swaggerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Huawei Inc.
#
---
name: upload-to-swagger-hub-only
# This job deletes API that is already published on swaggerhub.
on:
workflow_dispatch:
inputs:
VersionToBeDeleted:
type: string
description: Enter the version of the API that must be deleted.Eg., 1.0.1

env:
BOT_USER_NAME: eclipse-xpanse-bot
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
upload-to-swagger-hub:
runs-on: ubuntu-latest
env:
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }}
if: github.repository == 'eclipse-xpanse/xpanse'
permissions:
packages: write
steps:
- name: Install SwaggerHub CLI
run: npm i -g swaggerhub-cli

- name: Unpublish API
run: swaggerhub api:unpublish ${{ env.SWAGGERHUB_USER }}/XpanseRuntimeApi/v${{github.event.inputs.VersionToBeDeleted}}
continue-on-error: true

- name: Delete provided API version
run: swaggerhub api:delete ${{ env.SWAGGERHUB_USER }}/XpanseRuntimeApi/v${{github.event.inputs.VersionToBeDeleted}} --force
2 changes: 1 addition & 1 deletion .github/workflows/upload-swaggerhub-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:

- name: Create API as Non-default
if: ${{ github.event.inputs.IsDefaultVersion== 'false' }}
run: swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/XpanseRuntimeApi --file runtime/target/openapi.json --visibility=public --published=publish
run: swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/XpanseRuntimeApi --file runtime/target/openapi.json --visibility=public --published=publish

0 comments on commit 7a6ac91

Please sign in to comment.