Update OpenAPI #6463
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: Update OpenAPI | |
| on: | |
| schedule: | |
| - cron: "0 * * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check-openapi: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Run OpenAPI check | |
| run: make check-openapi | |
| - name: Check if update_openapi branch exists | |
| id: check_branch | |
| run: | | |
| if git ls-remote --heads origin update_openapi | grep update_openapi; then | |
| echo "Branch exists" | |
| echo "branch_exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Branch does not exist" | |
| echo "branch_exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Run OpenAPI update | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| run: make update-openapi | |
| - name: Set up JDK 11 | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 | |
| with: | |
| distribution: "temurin" | |
| java-version: "11" | |
| - name: Install OpenAPI Generator 7.11.0 | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| run: | | |
| wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.11.0/openapi-generator-cli-7.11.0.jar -O openapi-generator-cli.jar | |
| echo '#!/bin/sh' > /usr/local/bin/openapi-generator | |
| echo 'java -jar ${{ github.workspace }}/openapi-generator-cli.jar "$@"' >> /usr/local/bin/openapi-generator | |
| chmod +x /usr/local/bin/openapi-generator | |
| # Verify installation | |
| openapi-generator version | |
| - name: Install pnpm | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Set up Go | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.4.0 | |
| with: | |
| go-version: "1.23" | |
| cache: true | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable | |
| with: | |
| toolchain: stable | |
| components: clippy, rustfmt | |
| - name: Cache Cargo dependencies | |
| uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| rust/target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Install oapi-codegen | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| run: | | |
| go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest | |
| - name: Install dependencies and run orval in typescript folder | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| working-directory: ./typescript | |
| run: | | |
| pnpm install | |
| pnpm orval | |
| - name: Run make python-client in python folder | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| working-directory: ./python | |
| run: make python-client | |
| - name: Run make client in go folder | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| working-directory: ./go | |
| run: make client | |
| - name: Run make generate in rust folder | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| working-directory: ./rust | |
| run: make generate | |
| - name: Remove OpenAPI Generator JAR | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| run: rm -f openapi-generator-cli.jar | |
| - name: Create Pull Request | |
| if: steps.check_branch.outputs.branch_exists == 'false' | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | |
| with: | |
| branch: update_openapi | |
| base: main | |
| delete-branch: true | |
| title: "Update OpenAPI specification and generated code" | |
| body: | | |
| This PR was automatically generated by the OpenAPI update workflow. | |
| It contains: | |
| - Updated OpenAPI specifications | |
| - Generated TypeScript code from the updated specs | |
| - Generated Python client from the updated specs | |
| - Generated Go client from the updated specs | |
| - Generated Rust client from the updated specs | |
| commit-message: "chore: update OpenAPI spec and generated code" | |
| sign-commits: true | |
| labels: automated-pr, api-update | |
| draft: always-true |