Compare commits

...

1 Commits

Author SHA1 Message Date
Bentlybro
b7d08c47ec fix(ci): prevent Claude docs reviewer from editing same comment repeatedly
Issue: When new commits are pushed quickly, the workflow cancels previous
runs but Claude Code action finds and edits existing comments instead of
creating new ones, resulting in 13+ edits of the same comment.

Root cause: Cleanup step runs AFTER Claude review, so cancelled workflows
never delete old comments. Claude then finds and reuses existing comments.

Fix: Move cleanup step BEFORE Claude review so old comments are deleted
first, forcing each run to create a fresh comment.

Fixes the behavior seen in PR #12339 where one comment was edited 13 times
over 54 minutes due to cancelled workflow runs.
2026-03-09 13:50:13 +00:00

View File

@@ -57,6 +57,23 @@ jobs:
poetry install --only main poetry install --only main
poetry run prisma generate poetry run prisma generate
- name: Delete old Claude review comments
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get all comment IDs with our marker
COMMENT_IDS=$(gh api \
repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '[.[] | select(.body | contains("<!-- CLAUDE_DOCS_REVIEW -->")) | .id][]')
# Delete all old review comments
for COMMENT_ID in $COMMENT_IDS; do
if [ -n "$COMMENT_ID" ]; then
echo "Deleting old review comment: $COMMENT_ID"
gh api -X DELETE repos/${{ github.repository }}/issues/comments/$COMMENT_ID || true
fi
done
- name: Run Claude Code Review - name: Run Claude Code Review
uses: anthropics/claude-code-action@v1 uses: anthropics/claude-code-action@v1
with: with:
@@ -103,27 +120,3 @@ jobs:
Be constructive and specific. If everything looks good, say so! Be constructive and specific. If everything looks good, say so!
If there are issues, explain what's wrong and suggest how to fix it. If there are issues, explain what's wrong and suggest how to fix it.
- name: Delete old Claude review comments
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get all comment IDs with our marker, sorted by creation date (oldest first)
COMMENT_IDS=$(gh api \
repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '[.[] | select(.body | contains("<!-- CLAUDE_DOCS_REVIEW -->"))] | sort_by(.created_at) | .[].id')
# Count comments
COMMENT_COUNT=$(echo "$COMMENT_IDS" | grep -c . || true)
if [ "$COMMENT_COUNT" -gt 1 ]; then
# Delete all but the last (newest) comment
echo "$COMMENT_IDS" | head -n -1 | while read -r COMMENT_ID; do
if [ -n "$COMMENT_ID" ]; then
echo "Deleting old review comment: $COMMENT_ID"
gh api -X DELETE repos/${{ github.repository }}/issues/comments/$COMMENT_ID
fi
done
else
echo "No old review comments to clean up"
fi