Skip to content

Commit

Permalink
Merge pull request #814 from catenax-ng/feature/418-workflow-to-publi…
Browse files Browse the repository at this point in the history
…sh-api-to-swaggerhub

feat(impl):[#418] publish api to swagger hub
  • Loading branch information
ds-ext-kmassalski authored Mar 15, 2024
2 parents 693e234 + 6f52ba7 commit 736490a
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish-swagger-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: "Publish OpenAPI to Swaggerhub"

on:
workflow_call:
inputs:
version:
required: true
description: Version that will be published to Swaggerhub
type: string

jobs:
swagger-api:
runs-on: ubuntu-latest
env:
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }}
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }}
DOWNSTREAM_VERSION: ${{ inputs.version }}
steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup node
uses: actions/setup-node@v4

- name: Install Swagger 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 }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-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 }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-api.yaml --visibility=public --published=publish
swaggerhub api:setdefault ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }}
else
echo "[INFO] - snapshot, will set the API to 'unpublished'";
swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/item-relationship-service/${{ env.DOWNSTREAM_VERSION }} -f docs/src/api/irs-api.yaml --visibility=public --published=unpublish
fi
11 changes: 11 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ jobs:
needs:
- release
uses: ./.github/workflows/jira-publish-release.yaml
with:
version: ${{ github.ref_name }}
secrets: inherit

publish-to-swaggerhub:
name: "Publish OpenAPI spec to Swaggerhub"
permissions:
contents: read
needs:
- release
uses: ./.github/workflows/publish-swagger-hub.yml
with:
version: ${{ github.ref_name }}
secrets: inherit
13 changes: 7 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ https://github.com/google/google-java-format/blob/master/README.md#intellij-jre-
- Check if the changelog entries for the release are complete.
- Add the corresponding GitHub issue numbers to each entry if missing.
3. Update [COMPATIBILITY_MATRIX.md](COMPATIBILITY_MATRIX.md).
4. Create pull request from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/prepare-release-x.x.x) and merge to main.
5. Create Git tag for the desired release version `git tag x.x.x`
4. Update IRS API version in IrsApplication class and irs-api.yaml
5. Create pull request from [release preparation branch to main](https://github.com/eclipse-tractusx/item-relationship-service/compare/chore/prepare-release-x.x.x) and merge to main.
6. Create Git tag for the desired release version `git tag x.x.x`
(note: the irs-helm tag will be created automatically by the GitHub workflow based on the version in the irs-helm changelog).
6. Push Git tag to repository `git push origin x.x.x` (this will trigger the GitHub release workflow).
7. Wait for release workflow to complete.
8. Merge the automatically opened PR by GitHub actions bot.
9. Notify about the release in IRS Matrix Chat using the following template:
7. Push Git tag to repository `git push origin x.x.x` (this will trigger the GitHub release workflow).
8. Wait for release workflow to complete.
9. Merge the automatically opened PR by GitHub actions bot.
10. Notify about the release in IRS Matrix Chat using the following template:

> **IRS Release x.x.x**
>
Expand Down

0 comments on commit 736490a

Please sign in to comment.