diff --git a/.github/workflows/update-a2a-types.yml b/.github/workflows/update-a2a-types.yml new file mode 100644 index 00000000..b68beed6 --- /dev/null +++ b/.github/workflows/update-a2a-types.yml @@ -0,0 +1,81 @@ +name: Update A2A Schema from Specification + +on: + schedule: + - cron: "0 0 * * *" # Runs daily at 00:00 UTC + workflow_dispatch: + +jobs: + check_and_update: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Configure uv shell + run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH + + - name: Install dependencies (datamodel-code-generator) + run: uv sync + + - name: Define output file variable + id: vars + run: | + GENERATED_FILE="./src/a2a/types.py" + echo "GENERATED_FILE=$GENERATED_FILE" >> "$GITHUB_OUTPUT" + + - name: Run datamodel-codegen + run: | + set -euo pipefail # Exit immediately if a command exits with a non-zero status + + REMOTE_URL="https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json" + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" + + echo "Running datamodel-codegen..." + uv run datamodel-codegen \ + --url "$REMOTE_URL" \ + --input-file-type jsonschema \ + --output "$GENERATED_FILE" \ + --target-python-version 3.10 \ + --output-model-type pydantic_v2.BaseModel \ + --disable-timestamp \ + --use-schema-description \ + --use-union-operator \ + --use-field-description \ + --use-default \ + --use-default-kwarg \ + --use-one-literal-as-default \ + --class-name A2A \ + --use-standard-collections + echo "Codegen finished." + + - name: Create Pull Request if generated file changed + uses: peter-evans/create-pull-request@v6 + with: + committer: a2a-bot + author: a2a-bot + commit-message: "chore: 🤖 Auto-update A2A schema from specification" + title: "chore: 🤖 Auto-update A2A Schema from Specification" + body: | + This PR automatically updates the A2A schema types based on the latest specification. + + This update was triggered by the scheduled workflow run. + See the workflow run details: [${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + branch: "a2a-schema-update" + base: main + labels: | + automated + dependencies + add-paths: ${{ steps.vars.outputs.GENERATED_FILE }}