Skip to content

Commit

Permalink
chore(ci): add OpenAPI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
undrcrxwn committed Feb 9, 2024
1 parent 9a5957e commit c1329a3
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/openapi.yml
Original file line number Diff line number Diff line change
@@ -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 }}
13 changes: 11 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -83,4 +92,4 @@ jobs:
uses: ./.github/workflows/deployment.yml
with:
version: ${{ needs.version.outputs.tag }}
secrets: inherit
secrets: inherit

0 comments on commit c1329a3

Please sign in to comment.