|
| 1 | +name: Update A2A Schema from Specification |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [a2a_json_update] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + generate_and_pr: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: "3.10" |
| 23 | + |
| 24 | + - name: Install uv |
| 25 | + run: curl -LsSf https://astral.sh/uv/install.sh | sh |
| 26 | + |
| 27 | + - name: Configure uv shell |
| 28 | + run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH |
| 29 | + |
| 30 | + - name: Install dependencies (datamodel-code-generator) |
| 31 | + run: uv sync |
| 32 | + |
| 33 | + - name: Define output file variable |
| 34 | + id: vars |
| 35 | + run: | |
| 36 | + GENERATED_FILE="./src/a2a/types.py" |
| 37 | + echo "GENERATED_FILE=$GENERATED_FILE" >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + - name: Run datamodel-codegen |
| 40 | + run: | |
| 41 | + set -euo pipefail # Exit immediately if a command exits with a non-zero status |
| 42 | +
|
| 43 | + REMOTE_URL="https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json" |
| 44 | + GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}" |
| 45 | +
|
| 46 | + echo "Running datamodel-codegen..." |
| 47 | + uv run datamodel-codegen \ |
| 48 | + --url "$REMOTE_URL" \ |
| 49 | + --input-file-type jsonschema \ |
| 50 | + --output "$GENERATED_FILE" \ |
| 51 | + --target-python-version 3.10 \ |
| 52 | + --output-model-type pydantic_v2.BaseModel \ |
| 53 | + --disable-timestamp \ |
| 54 | + --use-schema-description \ |
| 55 | + --use-union-operator \ |
| 56 | + --use-field-description \ |
| 57 | + --use-default \ |
| 58 | + --use-default-kwarg \ |
| 59 | + --use-one-literal-as-default \ |
| 60 | + --class-name A2A \ |
| 61 | + --use-standard-collections |
| 62 | + echo "Codegen finished." |
| 63 | +
|
| 64 | + - name: Create Pull Request with Updates |
| 65 | + uses: peter-evans/create-pull-request@v6 |
| 66 | + with: |
| 67 | + token: ${{ secrets.A2A_BOT_PAT }} |
| 68 | + committer: "a2a-bot <[email protected]>" |
| 69 | + author: "a2a-bot <[email protected]>" |
| 70 | + commit-message: "chore: 🤖Auto-update A2A types from google/A2A@${{ github.event.client_payload.sha }}" |
| 71 | + title: "chore: 🤖 Auto-update A2A types from google/A2A" |
| 72 | + body: | |
| 73 | + This PR updates `src/a2a/types.py` based on the latest `specification/json/a2a.json` from [google/A2A](https://github.com/google/A2A/commit/${{ github.event.client_payload.sha }}). |
| 74 | + branch: "auto-update-a2a-types-${{ github.event.client_payload.sha }}" |
| 75 | + base: main |
| 76 | + labels: | |
| 77 | + automated |
| 78 | + dependencies |
| 79 | + add-paths: ${{ steps.vars.outputs.GENERATED_FILE }} |
0 commit comments