Polish 4 (#3577)
Co-authored-by: Zeoic <zeorgaming@gmail.com> Co-authored-by: Fesaa <77553571+Fesaa@users.noreply.github.com>
This commit is contained in:
parent
b38400c092
commit
0ffe0228e5
30 changed files with 339 additions and 115 deletions
65
.github/workflows/openapi-gen.yml
vendored
Normal file
65
.github/workflows/openapi-gen.yml
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
name: Generate OpenAPI Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'develop', '!release/**' ]
|
||||
paths:
|
||||
- '**/*.cs'
|
||||
- '**/*.csproj'
|
||||
pull_request:
|
||||
branches: [ 'develop', '!release/**' ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
generate-openapi:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run on direct pushes to develop, not PRs
|
||||
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Install dependencies
|
||||
run: dotnet restore
|
||||
|
||||
- name: Build project
|
||||
run: dotnet build API/API.csproj --configuration Debug
|
||||
|
||||
- name: Get Swashbuckle version
|
||||
id: swashbuckle-version
|
||||
run: |
|
||||
VERSION=$(grep -o '<PackageReference Include="Swashbuckle.AspNetCore" Version="[^"]*"' API/API.csproj | grep -o 'Version="[^"]*"' | cut -d'"' -f2)
|
||||
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Found Swashbuckle.AspNetCore version: $VERSION"
|
||||
|
||||
- name: Install matching Swashbuckle CLI tool
|
||||
run: |
|
||||
dotnet new tool-manifest --force
|
||||
dotnet tool install Swashbuckle.AspNetCore.Cli --version ${{ steps.swashbuckle-version.outputs.VERSION }}
|
||||
|
||||
- name: Generate OpenAPI file
|
||||
run: dotnet swagger tofile --output openapi.json API/bin/Debug/net9.0/API.dll v1
|
||||
|
||||
- name: Check for changes
|
||||
id: git-check
|
||||
run: |
|
||||
git add openapi.json
|
||||
git diff --staged --quiet openapi.json || echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Commit and push if changed
|
||||
if: steps.git-check.outputs.has_changes == 'true'
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
git commit -m "Update OpenAPI documentation" openapi.json
|
||||
git push
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.REPO_GHA_PAT }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue