Version Update Modal Rework + A few bugfixes #72
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') && github.repository_owner == 'Kareadita' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- 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 "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m "Update OpenAPI documentation" openapi.json | |
# Pull latest changes with rebase to avoid merge commits | |
git pull --rebase origin develop | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.REPO_GHA_PAT }} |