Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fd4eb11

Browse files
committedMay 20, 2025
ci: Change Update A2A Types to use Pull Request instead of Push
1 parent 14e4019 commit fd4eb11

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed
 

‎.github/workflows/update-a2a-types.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ name: Update A2A Schema from Specification
22

33
on:
44
schedule:
5-
- cron: "0 0 * * *"
5+
- cron: '0 0 * * *'
66
workflow_dispatch:
77

88
jobs:
99
check_and_update:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
pull-requests: write
1114

1215
steps:
1316
- name: Checkout code
@@ -16,7 +19,7 @@ jobs:
1619
- name: Set up Python
1720
uses: actions/setup-python@v5
1821
with:
19-
python-version: "3.13"
22+
python-version: '3.13'
2023

2124
- name: Install uv
2225
run: curl -LsSf https://astral.sh/uv/install.sh | sh
@@ -58,29 +61,56 @@ jobs:
5861
--use-standard-collections
5962
echo "Codegen finished."
6063
61-
- name: Commit and push if generated file changed
62-
if: github.ref == 'refs/heads/main' # Or your default branch name
64+
- name: Check for changes, commit, and push branch
65+
id: commit_push_check
6366
run: |
6467
set -euo pipefail
6568
6669
GENERATED_FILE="${{ steps.vars.outputs.GENERATED_FILE }}"
70+
PR_BRANCH="auto-update/a2a-schema" # Define the branch name for the PR
71+
COMMIT_MESSAGE="🤖 chore: Auto-update A2A schema from specification"
6772
6873
# Check if the generated file has any changes compared to HEAD
6974
if git diff --quiet "$GENERATED_FILE"; then
7075
echo "$GENERATED_FILE has no changes after codegen. Nothing to commit."
76+
echo "changes_detected=false" >> "$GITHUB_OUTPUT" # Set output to indicate no changes
7177
else
72-
echo "Changes detected in $GENERATED_FILE. Committing..."
78+
echo "Changes detected in $GENERATED_FILE."
79+
7380
# Configure git user for the commit
7481
git config user.name "github-actions"
7582
git config user.email "github-actions@github.com"
7683
84+
# Create and switch to the PR branch
85+
git checkout -B "$PR_BRANCH"
86+
7787
# Add the generated file
7888
git add "$GENERATED_FILE"
7989
8090
# Commit changes
81-
git commit -m "🤖 chore: Auto-update A2A schema from specification"
91+
git commit -m "$COMMIT_MESSAGE"
8292
83-
# Push changes
84-
git push
85-
echo "Changes committed and pushed."
93+
# Push changes to the PR branch, overwrite if it exists
94+
git push --force-with-lease --set-upstream origin "$PR_BRANCH"
95+
echo "Changes committed and pushed to branch $PR_BRANCH."
96+
echo "changes_detected=true" >> "$GITHUB_OUTPUT"
8697
fi
98+
99+
- name: Create Pull Request
100+
if: steps.commit_push_check.outputs.changes_detected == 'true'
101+
uses: peter-evans/create-pull-request@v6
102+
with:
103+
# Use the GITHUB_TOKEN provided by GitHub Actions
104+
token: ${{ secrets.GITHUB_TOKEN }}
105+
branch: auto-update/a2a-schema
106+
base: main
107+
title: '🤖 chore: Auto-update A2A schema from specification'
108+
body: |
109+
This PR was automatically generated by the GitHub Actions workflow `Update A2A Schema from Specification`.
110+
111+
It updates the `./src/a2a/types.py` file based on the latest schema specification available at:
112+
https://raw.githubusercontent.com/google/A2A/refs/heads/main/specification/json/a2a.json
113+
114+
labels: |
115+
automated pr
116+
chore

0 commit comments

Comments
 (0)
Please sign in to comment.