@@ -2,12 +2,15 @@ name: Update A2A Schema from Specification
2
2
3
3
on :
4
4
schedule :
5
- - cron : " 0 0 * * *"
5
+ - cron : ' 0 0 * * *'
6
6
workflow_dispatch :
7
7
8
8
jobs :
9
9
check_and_update :
10
10
runs-on : ubuntu-latest
11
+ permissions :
12
+ contents : write
13
+ pull-requests : write
11
14
12
15
steps :
13
16
- name : Checkout code
16
19
- name : Set up Python
17
20
uses : actions/setup-python@v5
18
21
with :
19
- python-version : " 3.13"
22
+ python-version : ' 3.13'
20
23
21
24
- name : Install uv
22
25
run : curl -LsSf https://astral.sh/uv/install.sh | sh
@@ -58,29 +61,56 @@ jobs:
58
61
--use-standard-collections
59
62
echo "Codegen finished."
60
63
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
63
66
run : |
64
67
set -euo pipefail
65
68
66
69
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"
67
72
68
73
# Check if the generated file has any changes compared to HEAD
69
74
if git diff --quiet "$GENERATED_FILE"; then
70
75
echo "$GENERATED_FILE has no changes after codegen. Nothing to commit."
76
+ echo "changes_detected=false" >> "$GITHUB_OUTPUT" # Set output to indicate no changes
71
77
else
72
- echo "Changes detected in $GENERATED_FILE. Committing..."
78
+ echo "Changes detected in $GENERATED_FILE."
79
+
73
80
# Configure git user for the commit
74
81
git config user.name "github-actions"
75
82
git config user.email "github-actions@github.com"
76
83
84
+ # Create and switch to the PR branch
85
+ git checkout -B "$PR_BRANCH"
86
+
77
87
# Add the generated file
78
88
git add "$GENERATED_FILE"
79
89
80
90
# Commit changes
81
- git commit -m "🤖 chore: Auto-update A2A schema from specification "
91
+ git commit -m "$COMMIT_MESSAGE "
82
92
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"
86
97
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