-
Notifications
You must be signed in to change notification settings - Fork 5
ci: add automated SDK definition sync workflow #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4aa8c83
8326df9
59cf132
0784571
43c8ab6
4925f72
0b9dd4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,100 @@ | ||||||||
| name: Update SDK definitions | ||||||||
|
|
||||||||
| on: | ||||||||
| schedule: | ||||||||
| - cron: "0 8 * * *" # daily at 08:00 UTC | ||||||||
| workflow_dispatch: | ||||||||
| repository_dispatch: | ||||||||
| types: [update-sdk-definitions] | ||||||||
|
|
||||||||
| permissions: | ||||||||
| contents: write | ||||||||
| pull-requests: write | ||||||||
|
|
||||||||
| jobs: | ||||||||
| update-definitions: | ||||||||
| name: Regenerate SDK clients from upstream OpenAPI specs | ||||||||
| runs-on: ubuntu-latest | ||||||||
| steps: | ||||||||
| - name: Checkout | ||||||||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||||||||
| with: | ||||||||
| ref: main | ||||||||
|
|
||||||||
| - name: Setup Bun | ||||||||
| uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | ||||||||
|
|
||||||||
| - name: Setup Node.js | ||||||||
| uses: actions/setup-node@49933ea5288caeca8642195f2b846f73898f2e17 # v4.4.0 | ||||||||
| with: | ||||||||
|
mendral-app[bot] marked this conversation as resolved.
mendral-app[bot] marked this conversation as resolved.
|
||||||||
| node-version: "22" | ||||||||
|
|
||||||||
| - name: Install dependencies | ||||||||
| run: bun install | ||||||||
|
|
||||||||
| - name: Regenerate sandbox SDK client | ||||||||
| run: | | ||||||||
| echo "Downloading sandbox definition from blaxel-ai/sandbox" | ||||||||
| curl -sf -o ./definition.yml \ | ||||||||
| "https://raw.githubusercontent.com/blaxel-ai/sandbox/refs/heads/main/sandbox-api/docs/openapi.yml" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (P3): OpenAPI spec is fetched over HTTPS without checksum verification. A compromised upstream could inject malicious type definitions into generated SDK code. Consider pinning to a specific commit SHA in the raw URL. Suggested change
Suggested change
Prompt for AI agents |
||||||||
|
|
||||||||
| rm -rf @blaxel/core/src/sandbox/client/types.gen.ts @blaxel/core/src/sandbox/client/sdk.gen.ts | ||||||||
| npx @hey-api/openapi-ts@0.66.0 -i ./definition.yml -o ./tmp/ -c @hey-api/client-fetch | ||||||||
|
mendral-app[bot] marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maintainability (P2): Running Prompt for AI agentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Agentic Security Review Reviewed by Cursor Security Reviewer for commit 0b9dd4f. Configure here. |
||||||||
| cp -r ./tmp/* @blaxel/core/src/sandbox/client | ||||||||
|
|
||||||||
| sed -i 's/from '\''\.\/sdk\.gen'\''/from '\''\.\/sdk\.gen\.js'\''/g' @blaxel/core/src/sandbox/client/index.ts | ||||||||
| sed -i 's/from '\''\.\/types\.gen'\''/from '\''\.\/types\.gen\.js'\''/g' @blaxel/core/src/sandbox/client/index.ts | ||||||||
| rm -rf ./tmp definition.yml | ||||||||
|
|
||||||||
| - name: Regenerate controlplane SDK client | ||||||||
| run: | | ||||||||
| echo "Downloading controlplane definition from blaxel-ai/controlplane" | ||||||||
| curl -sf -o ./definition.yml \ | ||||||||
| "https://api.blaxel.ai/v0/openapi/controlplane.yml" | ||||||||
|
|
||||||||
|
mendral-app[bot] marked this conversation as resolved.
|
||||||||
| rm -rf @blaxel/core/src/client/types.gen.ts @blaxel/core/src/client/sdk.gen.ts | ||||||||
| npx @hey-api/openapi-ts@0.66.0 -i ./definition.yml -o ./tmp/ -c @hey-api/client-fetch | ||||||||
| cp -r ./tmp/* @blaxel/core/src/client | ||||||||
|
|
||||||||
| sed -i 's/from '\''\.\/sdk\.gen'\''/from '\''\.\/sdk\.gen\.js'\''/g' @blaxel/core/src/client/index.ts | ||||||||
| sed -i 's/from '\''\.\/types\.gen'\''/from '\''\.\/types\.gen\.js'\''/g' @blaxel/core/src/client/index.ts | ||||||||
| sed -i 's/from '\''\.\/types\.gen'\''/from '\''\.\/types\.gen\.js'\''/g' @blaxel/core/src/client/sdk.gen.ts | ||||||||
| perl -i -0777 -pe 's/(\{\s*scheme: .bearer.,\s*type: .http.\s*\}),\s*\{\s*scheme: .bearer.,\s*type: .http.\s*\}/$1/g' @blaxel/core/src/client/sdk.gen.ts | ||||||||
| sed -i 's/\([A-Za-z_][A-Za-z0-9_]*\)Readable/\1/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| sed -i 's/TimeFieldsWritable/TimeFields/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| sed -i 's/OwnerFieldsWritable/OwnerFields/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| sed -i 's/export type Function =/export type _Function =/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| sed -i 's/: Function;/: _Function;/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| sed -i 's/<Function>/<_Function>/g' @blaxel/core/src/client/types.gen.ts | ||||||||
| echo '' >> @blaxel/core/src/client/types.gen.ts | ||||||||
| echo 'export type DriveStateWritable = DriveState;' >> @blaxel/core/src/client/types.gen.ts | ||||||||
| rm -rf ./tmp definition.yml | ||||||||
|
|
||||||||
| - name: Check for changes | ||||||||
| id: diff | ||||||||
| run: | | ||||||||
| if [ -z "$(git status --porcelain)" ]; then | ||||||||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||||||||
| echo "No definition changes detected" | ||||||||
| else | ||||||||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||||||||
| echo "Definition changes detected:" | ||||||||
| git status --short | ||||||||
| fi | ||||||||
|
|
||||||||
| - name: Create pull request | ||||||||
| if: steps.diff.outputs.changed == 'true' | ||||||||
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | ||||||||
| with: | ||||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||||
| branch: automated/update-sdk-definitions | ||||||||
| commit-message: "chore: update SDK definitions from upstream OpenAPI specs" | ||||||||
| title: "chore: update SDK definitions from upstream OpenAPI specs" | ||||||||
| body: | | ||||||||
| Automated PR to sync the generated SDK clients with the latest OpenAPI specs from: | ||||||||
| - [`blaxel-ai/sandbox`](https://github.com/blaxel-ai/sandbox) (sandbox client) | ||||||||
| - [`blaxel-ai/controlplane`](https://github.com/blaxel-ai/controlplane) (controlplane client) | ||||||||
|
|
||||||||
| Generated by the **Update SDK definitions** workflow. | ||||||||
| labels: automated | ||||||||
| delete-branch: true | ||||||||


Uh oh!
There was an error while loading. Please reload this page.