Skip to content

Commit f31b341

Browse files
committed
ci: Add auto-format workflow
1 parent 0c9df12 commit f31b341

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/auto-format.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Auto-format with Nox
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
format:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
token: ${{ secrets.A2A_BOT_PAT }}
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.x"
25+
26+
- name: Install Nox
27+
run: pip install nox
28+
29+
- name: Run Nox formatting session
30+
run: nox -s format
31+
32+
- name: Check for changes and commit if any
33+
id: commit_changes
34+
run: |
35+
git config user.name "a2a-bot"
36+
git config user.email "a2a-bot@google.com"
37+
38+
# Check if there are any changes after running Nox
39+
if [ -n "$(git status --porcelain)" ]; then
40+
echo "::notice file=./.github/workflows/auto-format.yml::Formatting changes detected. Committing..."
41+
git add .
42+
git commit -m "chore(format): Auto-format code with Nox"
43+
git push origin HEAD:${{ github.event.pull_request.head.ref }}
44+
echo "changes_committed=true" >> "$GITHUB_OUTPUT"
45+
else
46+
echo "No formatting changes detected. Repository is clean."
47+
echo "changes_committed=false" >> "$GITHUB_OUTPUT"
48+
fi

0 commit comments

Comments
 (0)