Skip to content

Commit e15aadd

Browse files
authored
ci: Create GitHub Action to generate types.py from specification JSON (#81)
1 parent e696c8d commit e15aadd

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Update A2A Schema from Specification
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *" # Runs daily at 00:00 UTC
6+
workflow_dispatch:
7+
8+
jobs:
9+
check_and_update:
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.13"
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 if generated file changed
65+
uses: peter-evans/create-pull-request@v6
66+
with:
67+
committer: a2a-bot <[email protected]>
68+
author: a2a-bot <[email protected]>
69+
commit-message: "chore: 🤖 Auto-update A2A schema from specification"
70+
title: "chore: 🤖 Auto-update A2A Schema from Specification"
71+
body: |
72+
This PR automatically updates the A2A schema types based on the latest specification.
73+
74+
This update was triggered by the scheduled workflow run.
75+
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 }})
76+
branch: "a2a-schema-update"
77+
base: main
78+
labels: |
79+
automated
80+
dependencies
81+
add-paths: ${{ steps.vars.outputs.GENERATED_FILE }}

0 commit comments

Comments
 (0)