Skip to content

Commit b75c429

Browse files
committed
claude_update_comment
1 parent 076886d commit b75c429

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

.github/workflows/claude-review.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Claude Code Review
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened]
65
branches: [main, cloud, devel]
76

87
concurrency:
@@ -44,7 +43,18 @@ jobs:
4443
env:
4544
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
4645
run: |
47-
claude /review --max-turns "${{ env.CLAUDE_MAX_TURNS }}" --model "${{ env.CLAUDE_MODEL }}" > /tmp/review_output.md 2>&1 || {
46+
claude -p "Review the changes in this pull request. Use git diff ${{ github.event.pull_request.base.ref }}...HEAD to see the changes. Focus on:
47+
- Code quality and best practices
48+
- Potential bugs or issues
49+
- Security concerns
50+
- Performance implications
51+
- Compliance with the project standards outlined in CLAUDE.md
52+
53+
Provide a concise review in markdown format." \
54+
--max-turns "${{ env.CLAUDE_MAX_TURNS }}" \
55+
--model "${{ env.CLAUDE_MODEL }}" \
56+
--allowedTools "Bash(git diff *),Bash(git log *),Bash(git show *),Read,Grep,Glob" \
57+
> /tmp/review_output.md 2>&1 || {
4858
echo "Claude Code review encountered an error" > /tmp/review_output.md
4959
echo "" >> /tmp/review_output.md
5060
echo "⚠️ The automated review encountered an error. Please review manually." >> /tmp/review_output.md
@@ -65,12 +75,17 @@ jobs:
6575
review = '⚠️ Unable to read review output. The review may have failed.';
6676
}
6777
78+
// Marker to identify our comment
79+
const COMMENT_MARKER = '<!-- claude-code-review -->';
80+
6881
// Add header and metadata
69-
const comment = `## 🤖 Claude Code Review
82+
const body = `${COMMENT_MARKER}
83+
## 🤖 Claude Code Review
7084
7185
**PR**: #${{ github.event.pull_request.number }}
7286
**Base**: \`${{ github.event.pull_request.base.ref }}\`
7387
**Head**: \`${{ github.event.pull_request.head.ref }}\`
88+
**Commit**: \`${{ github.event.pull_request.head.sha }}\`
7489
7590
---
7691
@@ -80,9 +95,27 @@ jobs:
8095
8196
<sub>Model: ${{ env.CLAUDE_MODEL }}</sub>`;
8297
83-
await github.rest.issues.createComment({
98+
// Find existing comment
99+
const { data: comments } = await github.rest.issues.listComments({
84100
owner: context.repo.owner,
85101
repo: context.repo.repo,
86-
issue_number: context.issue.number,
87-
body: comment
102+
issue_number: context.issue.number
88103
});
104+
105+
const existingComment = comments.find(c => c.body.includes(COMMENT_MARKER));
106+
107+
if (existingComment) {
108+
await github.rest.issues.updateComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
comment_id: existingComment.id,
112+
body
113+
});
114+
} else {
115+
await github.rest.issues.createComment({
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
issue_number: context.issue.number,
119+
body
120+
});
121+
}

0 commit comments

Comments
 (0)