From c1329a31d8f9fb612ce8178b541ea99f33f71722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=BD=D0=BE=D0=B9=20=D0=B8=D1=88?= =?UTF-8?q?=D0=B0=D0=BA?= <69521267+undrcrxwn@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:03:53 +0300 Subject: [PATCH] chore(ci): add OpenAPI workflow --- .github/workflows/openapi.yml | 64 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 13 +++++-- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/openapi.yml diff --git a/.github/workflows/openapi.yml b/.github/workflows/openapi.yml new file mode 100644 index 0000000..7eec78b --- /dev/null +++ b/.github/workflows/openapi.yml @@ -0,0 +1,64 @@ +name: OpenAPI specification + +on: + workflow_call: + inputs: + openapi_asset_upload_url: + required: true + type: string + pull_request: + branches: + - master + +jobs: + produce-spec: + name: Produce openapi.yaml + runs-on: ubuntu-latest + steps: + - name: 🔽 Checkout repository + uses: actions/checkout@v4 + - name: ⚙️ Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '7.0.x' + - name: ⚒ Build solution + run: dotnet build + - name: ⚙️ Install Swashbuckle.AspNetCore.Cli + run: | + dotnet tool install Swashbuckle.AspNetCore.Cli --global + echo "$DOTNET_ROOT/tools/swagger" >> $GITHUB_PATH + - name: 📝 Generate OpenAPI specification + run: swagger tofile --output openapi.yaml --yaml ./src/CrowdParlay.Social.Api/bin/Debug/net7.0/CrowdParlay.Social.Api.dll v1 + - name: 🔗 Upload OpenAPI specification as release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ inputs.openapi_asset_upload_url }} + asset_path: openapi.yaml + asset_name: openapi.yaml + asset_content_type: application/yaml + integrate-spec: + name: Update API documentation + needs: produce-spec + uses: crowdparlay/foundation/.github/workflows/api-docs.yml@master + with: + publish: ${{ github.event_name != 'pull_request' }} + secrets: inherit + spec-diff: + name: Check API diff on Bump.sh + if: ${{ github.event_name == 'pull_request' }} + needs: integrate-spec + runs-on: ubuntu-latest + steps: + - name: 🔽 Checkout repository + uses: actions/checkout@v4 + - name: 🤖 Comment pull request with API diff + uses: bump-sh/github-action@v1 + with: + doc: ${{ vars.BUMP_SH_DOCUMENTATION }} + token: ${{ secrets.BUMP_SH_TOKEN }} + file: openapi.yaml + command: diff + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf30c3e..77e6b93 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,6 +40,8 @@ jobs: name: Publish GitHub release needs: version runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.release.outputs.upload_url }} steps: - name: 🔽 Checkout repository uses: actions/checkout@v4 @@ -55,14 +57,21 @@ jobs: skip-tag: true skip-commit: true - name: 🎁 Publish GitHub release + id: release uses: actions/create-release@v1 - if: ${{ steps.changelog.outputs.skipped == 'false' }} env: GITHUB_TOKEN: ${{ secrets.github_token }} with: tag_name: ${{ needs.version.outputs.tag }} release_name: ${{ needs.version.outputs.tag }} body: ${{ steps.changelog.outputs.clean_changelog }} + publish-api: + name: Publish API + needs: release + uses: ./.github/workflows/openapi.yml + with: + openapi_asset_upload_url: ${{ needs.release.outputs.upload_url }} + secrets: inherit deliver: name: Deliver needs: version @@ -83,4 +92,4 @@ jobs: uses: ./.github/workflows/deployment.yml with: version: ${{ needs.version.outputs.tag }} - secrets: inherit \ No newline at end of file + secrets: inherit