Skip to content

Commit f9ce4cb

Browse files
committed
fix: remove dependency for claude fixer on github cli
1 parent 6b89cb0 commit f9ce4cb

1 file changed

Lines changed: 42 additions & 34 deletions

File tree

.github/workflows/claude-fixer.yml

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -142,39 +142,47 @@ jobs:
142142
branch: ${{ steps.branch.outputs.name }}
143143
create_branch: true
144144

145-
- name: Open pull request
145+
- name: Open pull request and post failure logs
146146
if: steps.auto-commit.outputs.changes_detected == 'true'
147-
id: create-pr
148-
env:
149-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150-
run: |
151-
PR_URL=$(gh pr create \
152-
--title "fix: auto-fix ${{ github.event.workflow_run.name }} failures on ${{ github.event.workflow_run.head_branch }}" \
153-
--body "Failures detected in \`${{ github.event.workflow_run.name }}\` on branch \`${{ github.event.workflow_run.head_branch }}\`.
154-
155-
This PR was automatically generated by the Claude Test Fixer workflow.
156-
157-
> ⚠️ AI-generated fix. Please review carefully before merging." \
158-
--base ${{ github.event.workflow_run.head_branch }} \
159-
--head ${{ steps.branch.outputs.name }})
160-
echo "pr-url=$PR_URL" >> $GITHUB_OUTPUT
147+
uses: actions/github-script@v7
148+
with:
149+
github-token: ${{ secrets.GITHUB_TOKEN }}
150+
script: |
151+
const { data: pr } = await github.rest.pulls.create({
152+
owner: context.repo.owner,
153+
repo: context.repo.repo,
154+
title: 'fix: auto-fix ${{ github.event.workflow_run.name }} failures on ${{ github.event.workflow_run.head_branch }}',
155+
body: [
156+
'Failures detected in `${{ github.event.workflow_run.name }}` on branch `${{ github.event.workflow_run.head_branch }}`.',
157+
'',
158+
'This PR was automatically generated by the Claude Test Fixer workflow.',
159+
'',
160+
'> ⚠️ AI-generated fix. Please review carefully before merging.',
161+
].join('\n'),
162+
head: '${{ steps.branch.outputs.name }}',
163+
base: '${{ github.event.workflow_run.head_branch }}',
164+
});
165+
166+
const fs = require('fs');
167+
let logs = fs.readFileSync('/tmp/failed_logs.txt', 'utf8');
168+
if (logs.length > 60000) {
169+
logs = logs.substring(0, 60000) + '\n... (truncated — see full logs in the failed workflow run)';
170+
}
161171
162-
- name: Add failure logs as PR comment
163-
if: steps.auto-commit.outputs.changes_detected == 'true'
164-
env:
165-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166-
run: |
167-
{
168-
echo '## Test Failure Logs'
169-
echo ''
170-
echo '<details>'
171-
echo '<summary>Click to expand failure logs from the failed CI run</summary>'
172-
echo ''
173-
echo '```'
174-
head -c 60000 /tmp/failed_logs.txt
175-
echo '```'
176-
echo ''
177-
echo '</details>'
178-
} > /tmp/pr-comment.md
179-
180-
gh pr comment "${{ steps.create-pr.outputs.pr-url }}" --body-file /tmp/pr-comment.md
172+
await github.rest.issues.createComment({
173+
owner: context.repo.owner,
174+
repo: context.repo.repo,
175+
issue_number: pr.number,
176+
body: [
177+
'## Test Failure Logs',
178+
'',
179+
'<details>',
180+
'<summary>Click to expand failure logs from the failed CI run</summary>',
181+
'',
182+
'```',
183+
logs,
184+
'```',
185+
'',
186+
'</details>',
187+
].join('\n'),
188+
});

0 commit comments

Comments
 (0)