Skip to content

Commit 60c150f

Browse files
committed
fix: git workflow on claude fixer
1 parent 6fd7f50 commit 60c150f

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

.github/workflows/claude-fixer.yml

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
with:
3333
ref: ${{ github.event.workflow_run.head_branch }}
34+
token: ${{ secrets.GITHUB_TOKEN }}
3435
fetch-depth: 0
3536

3637
- name: Use Node.js 24
@@ -45,6 +46,15 @@ jobs:
4546

4647
- run: npm ci
4748

49+
- name: Configure git identity
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
- name: Generate fix branch name
55+
id: branch
56+
run: echo "name=fix/claude-auto-$(date +%s)" >> $GITHUB_OUTPUT
57+
4858
- name: Fetch and filter failure logs from all shards
4959
id: fetch-logs
5060
env:
@@ -112,10 +122,35 @@ jobs:
112122
113123
4. **Iterate until all tests pass**: If tests still fail after a fix, re-read the output, deepen your understanding of the root cause, and refine the fix. Do not give up and do not apply increasingly speculative patches. Each iteration must be grounded in analysis.
114124
115-
5. **Create a PR only after all failing tests pass**:
116-
- Create a new branch from "${{ github.event.workflow_run.head_branch }}" (e.g. `fix/claude-auto-<short-description>`)
117-
- Commit the changes with a descriptive message explaining the root cause and fix
118-
- Open a pull request targeting "${{ github.event.workflow_run.head_branch }}"
125+
5. **Stop once all tests pass** — do NOT run any git commands. The workflow will handle committing and opening the PR.
119126
120127
additional_permissions: |
121128
actions: read
129+
130+
- name: Restore git remote auth
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
run: git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git
134+
135+
- name: Commit fixes
136+
id: auto-commit
137+
uses: stefanzweifel/git-auto-commit-action@v5
138+
with:
139+
commit_message: "fix: auto-fix test failures from ${{ github.event.workflow_run.name }}"
140+
branch: ${{ steps.branch.outputs.name }}
141+
create_branch: true
142+
143+
- name: Open pull request
144+
if: steps.auto-commit.outputs.changes_detected == 'true'
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
run: |
148+
gh pr create \
149+
--title "fix: auto-fix test failures from ${{ github.event.workflow_run.name }}" \
150+
--body "Failures detected in \`${{ github.event.workflow_run.name }}\` on branch \`${{ github.event.workflow_run.head_branch }}\`.
151+
152+
This PR was automatically generated by the Claude Test Fixer workflow.
153+
154+
> ⚠️ AI-generated fix. Please review carefully before merging." \
155+
--base ${{ github.event.workflow_run.head_branch }} \
156+
--head ${{ steps.branch.outputs.name }}

0 commit comments

Comments
 (0)