Add automated OpenAPI schema generation workflow (#6) #1
This file contains hidden or 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: | |
| - main | |
| - develop | |
| - fastapi | |
| jobs: | |
| generate-openapi: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12.x' | |
| - name: Install PDM | |
| run: pip install pdm | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .venv | |
| __pypackages__ | |
| key: ${{ runner.os }}-pdm-${{ hashFiles('**/pdm.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pdm- | |
| - name: Install dependencies | |
| run: pdm install --no-self | |
| - name: Generate OpenAPI JSON | |
| run: pdm run python scripts/generate_openapi.py | |
| - name: Commit and push if changed | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add docs/openapi.json | |
| git diff --staged --quiet || git commit -m "chore: update OpenAPI documentation [skip ci: openapi-update]" | |
| git push |