From bf94846624f1b9a135afc22d2dc08cbda62009ca Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 10 Aug 2025 20:23:02 -0400 Subject: [PATCH] Update GitHub workflow to replace existing Continue CLI review comments instead of creating multiple comments --- .github/workflows/continue-review.yaml | 43 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continue-review.yaml b/.github/workflows/continue-review.yaml index 67bdc135e..723308b01 100644 --- a/.github/workflows/continue-review.yaml +++ b/.github/workflows/continue-review.yaml @@ -197,8 +197,6 @@ jobs: reviewContent = '⚠️ AI review completed but no review output was generated. Check the action logs for details.'; } - const comment = reviewContent; - // Get PR number let prNumber; if (context.payload.pull_request) { @@ -207,19 +205,48 @@ jobs: prNumber = context.payload.workflow_run.pull_requests[0].number; } - if (prNumber) { + if (!prNumber) { + console.log('Could not determine PR number for commenting'); + return; + } + + // Unique identifier for our bot comments + const botSignature = ''; + const newComment = `${botSignature}\n${reviewContent}`; + + // Get all comments on the PR + const { data: comments } = await github.rest.issues.listComments({ + issue_number: prNumber, + owner: context.repo.owner, + repo: context.repo.repo, + }); + + // Find existing Continue CLI review comment + const existingComment = comments.find(comment => + comment.body.includes(botSignature) + ); + + if (existingComment) { + // Update existing comment + await github.rest.issues.updateComment({ + comment_id: existingComment.id, + owner: context.repo.owner, + repo: context.repo.repo, + body: newComment + }); + console.log(`Successfully updated existing comment #${existingComment.id} on PR #${prNumber}`); + } else { + // Create new comment await github.rest.issues.createComment({ issue_number: prNumber, owner: context.repo.owner, repo: context.repo.repo, - body: comment + body: newComment }); - console.log(`Successfully posted comment on PR #${prNumber}`); - } else { - console.log('Could not determine PR number for commenting'); + console.log(`Successfully created new comment on PR #${prNumber}`); } } catch (error) { - console.log('Failed to post comment:', error.message); + console.log('Failed to post/update comment:', error.message); console.log('Error details:', error); } env: