Skip to content

Update A2A Schema from Specification #6

Update A2A Schema from Specification

Update A2A Schema from Specification #6

name: Update A2A Schema from Specification
on:
schedule:
- cron: '0 0 * * *'
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: Check for changes, commit, and push branch
id: commit_push_check
run: |
set -euo pipefail
GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}"
PR_BRANCH="auto-update/a2a-schema" # Define the branch name for the PR
COMMIT_MESSAGE="🤖 chore: Auto-update A2A schema from specification"
# Check if the generated file has any changes compared to HEAD
if git diff --quiet "$GENERATED_FILE"; then
echo "$GENERATED_FILE has no changes after codegen. Nothing to commit."
echo "changes_detected=false" >> "$GITHUB_OUTPUT" # Set output to indicate no changes
else
echo "Changes detected in $GENERATED_FILE."
# Configure git user for the commit
git config user.name "github-actions"
git config user.email "[email protected]"
# Create and switch to the PR branch
git checkout -B "$PR_BRANCH"
# Add the generated file
git add "$GENERATED_FILE"
# Commit changes
git commit -m "$COMMIT_MESSAGE"
# Push changes to the PR branch, overwrite if it exists
git push --force-with-lease --set-upstream origin "$PR_BRANCH"
echo "Changes committed and pushed to branch $PR_BRANCH."
echo "changes_detected=true" >> "$GITHUB_OUTPUT"
fi
- name: Create Pull Request
if: steps.commit_push_check.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
# Use the GITHUB_TOKEN provided by GitHub Actions
token: ${{ secrets.GITHUB_TOKEN }}
branch: auto-update/a2a-schema
base: main
title: '🤖 chore: Auto-update A2A schema from specification'
body: |
This PR was automatically generated by the GitHub Actions workflow `Update A2A Schema from Specification`.
It updates the `./src/a2a/types.py` file based on the latest schema specification available at:
https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json
labels: |
automated pr
chore