Repository navigation
.github/workflows/sync-agent-sdk-openapi.yml #132
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: Sync agent-sdk OpenAPI | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' # nightly catch-up | |
| workflow_dispatch: | |
| inputs: | |
| agent_sdk_ref: | |
| description: 'Agent SDK branch/tag/commit to generate from' | |
| required: false | |
| default: 'main' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-openapi: | |
| runs-on: ubuntu-latest | |
| env: | |
| # GITHUB_TOKEN is fine. | |
| GH_CLONE_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # For workflow_dispatch this will be set; for push/schedule it will fall back to main. | |
| AGENT_SDK_REF: ${{ github.event.inputs.agent_sdk_ref || 'main' }} | |
| steps: | |
| - name: Checkout docs repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Checkout agent-sdk | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: OpenHands/agent-sdk | |
| path: agent-sdk | |
| ref: ${{ env.AGENT_SDK_REF }} | |
| fetch-depth: 0 | |
| # If private, uncomment: | |
| # token: ${{ env.GH_CLONE_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config user.name "all-hands-bot" | |
| git config user.email "contact@all-hands.dev" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Generate OpenAPI spec | |
| working-directory: agent-sdk | |
| env: | |
| SCHEMA_PATH: ${{ github.workspace }}/openapi/agent-sdk.json | |
| run: | | |
| set -euo pipefail | |
| make build | |
| mkdir -p "$(dirname "$SCHEMA_PATH")" | |
| uv run python openhands-agent-server/openhands/agent_server/openapi.py | |
| - name: Detect changes | |
| id: detect_changes | |
| run: | | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| echo "changes=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changes=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create Pull Request with OpenAPI changes | |
| if: steps.detect_changes.outputs.changes == 'true' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: | | |
| docs(sync-openapi): agent-sdk ${{ env.AGENT_SDK_REF }} | |
| Generated from agent-sdk at `${{ env.AGENT_SDK_REF }}`. | |
| title: "chore(docs): sync agent-sdk OpenAPI" | |
| body: | | |
| This PR was automatically created by the nightly sync workflow. | |
| It updates the OpenAPI spec to match OpenHands/agent-sdk at `${{ env.AGENT_SDK_REF }}`. | |
| branch: chore/sync-openapi | |
| delete-branch: true | |
| signoff: false | |
| add-paths: | | |
| openapi/agent-sdk.json |