-
Notifications
You must be signed in to change notification settings - Fork 1
ci: add automated SDK definition sync workflow #151
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
base: main
Are you sure you want to change the base?
Changes from all commits
441d76f
c2be321
964c41e
a25fe38
123acd6
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,94 @@ | ||
| 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: Install uv | ||
| uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --group dev | ||
|
|
||
| - 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" | ||
|
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. 🔒 Agentic Security Review Impact: This creates a supply-chain path where compromised upstream specs can introduce malicious client code into an automated update PR, increasing the chance of trusted-but-poisoned changes being merged. Reviewed by Cursor Security Reviewer for commit 123acd6. Configure here. |
||
|
|
||
| rm -rf src/blaxel/core/sandbox/client/api src/blaxel/core/sandbox/client/models | ||
| .venv/bin/openapi-python-client generate \ | ||
| --path=definition.yml \ | ||
| --output-path=./tmp-sdk-sandbox \ | ||
| --overwrite \ | ||
| --custom-template-path=./templates \ | ||
| --config=./openapi-python-client.yml | ||
| cp -r ./tmp-sdk-sandbox/blaxel/* ./src/blaxel/core/sandbox/client | ||
| rm -rf ./tmp-sdk-sandbox 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" | ||
|
|
||
| rm -rf src/blaxel/core/client/api src/blaxel/core/client/models | ||
| .venv/bin/openapi-python-client generate \ | ||
| --path=definition.yml \ | ||
| --output-path=./tmp-sdk-python \ | ||
| --overwrite \ | ||
| --custom-template-path=./templates \ | ||
| --config=./openapi-python-client.yml | ||
| cp -r ./tmp-sdk-python/blaxel/* ./src/blaxel/core/client | ||
| rm -rf ./tmp-sdk-python definition.yml | ||
|
|
||
| - name: Format and lint | ||
| run: | | ||
| uv run ruff format | ||
| uv run ruff check --fix | ||
|
|
||
| - 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@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9 | ||
| 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.