Create index.md #14
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 API reference from OpenAPI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: ["main"] | |
| paths-ignore: | |
| - "examples/output.md" | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: generate-openapi-reference | |
| cancel-in-progress: true | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Generate Markdown | |
| run: | | |
| python openapi_to_human.py examples/openapi-min.yaml -o examples/output.md | |
| - name: Show generated output (first 120 lines) | |
| run: | | |
| echo "---- examples/output.md (first 120 lines) ----" | |
| sed -n '1,120p' examples/output.md | |
| - name: Commit generated Markdown back to repo | |
| run: | | |
| # Detect *any* changes, including untracked files like a brand-new output.md | |
| if [[ -z "$(git status --porcelain)" ]]; then | |
| echo "No changes to commit." | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add examples/output.md | |
| # If output.md is unchanged, git commit will fail — handle that gracefully | |
| git commit -m "chore: generate API reference from OpenAPI" || { | |
| echo "Nothing to commit (output unchanged)." | |
| exit 0 | |
| } | |
| git push | |
| - name: Upload generated Markdown as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openapi-human-reference-output | |
| path: examples/output.md |