Regenerate Client #44
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: Regenerate Client | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| regenerate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: 3060111 | |
| private-key: ${{ secrets.HOTDATA_AUTOMATION_PRIVATE_KEY }} | |
| owner: hotdata-dev | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Fetch merged OpenAPI spec | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| curl -sS -f -L \ | |
| -H "Accept: application/vnd.github.v3.raw" \ | |
| -H "Authorization: Bearer $GH_TOKEN" \ | |
| https://api.github.com/repos/hotdata-dev/www.hotdata.dev/contents/api/openapi.yaml \ | |
| -o openapi.yaml | |
| - name: Clean existing source | |
| run: rm -rf src/ | |
| - name: Generate client | |
| env: | |
| PACKAGE_VERSION: "0.1.0" | |
| run: | | |
| npx @openapitools/openapi-generator-cli generate \ | |
| -i openapi.yaml \ | |
| -g rust \ | |
| -o . \ | |
| -t .openapi-generator-templates \ | |
| --additional-properties=packageName=hotdata,packageVersion=$PACKAGE_VERSION,library=reqwest,supportAsync=true \ | |
| --http-user-agent "hotdata-rust/${PACKAGE_VERSION}" \ | |
| --skip-validate-spec | |
| - name: Clean up fetched spec | |
| run: rm -f openapi.yaml | |
| - name: Verify generated client compiles | |
| # cargo check is the drift tripwire for the template override — if | |
| # openapi-generator rearranges the auth-emission mustache variables | |
| # in a future version, the override will produce non-compiling code | |
| # and this step fails loudly instead of shipping wrong output. | |
| run: cargo check | |
| - name: Create PR | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| title: "chore: regenerate client from updated OpenAPI spec" | |
| branch: openapi-update-${{ github.run_id }} | |
| commit-message: "chore: regenerate client from OpenAPI spec" | |
| body: "Auto-generated from updated HotData OpenAPI spec." |