From 64bda6b2b3dac1037e9895dbee4ce1d35565e1fe Mon Sep 17 00:00:00 2001 From: Tomasz Stefaniak Date: Fri, 15 Aug 2025 14:25:26 -0700 Subject: [PATCH] fix: prevent review actions from running on draft PRs and deduplicate comments - Add draft PR check to both general-review and detailed-review actions - Add deduplication logic to filter identical comments (same path + position + body) - Include triggered-by message in detailed review body when initiated from comment - Remove redundant separate triggered-by comment --- actions/detailed-review/action.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/actions/detailed-review/action.yml b/actions/detailed-review/action.yml index 3c493ae44..97c47018f 100644 --- a/actions/detailed-review/action.yml +++ b/actions/detailed-review/action.yml @@ -304,12 +304,19 @@ runs: // Create the review if (comments.length > 0) { try { + let reviewBody = `${reviewData.review_summary || 'AI Code Review'}\n\n---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`; + + // Add triggered by note if from comment + if (context.eventName === 'issue_comment') { + reviewBody = `*Triggered by @${context.payload.comment.user.login}'s request*\n\n${reviewBody}`; + } + await github.rest.pulls.createReview({ owner: context.repo.owner, repo: context.repo.repo, pull_number: prNumber, commit_id: commitSha, - body: `${reviewData.review_summary || 'AI Code Review'}\n\n---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`, + body: reviewBody, event: 'COMMENT', comments: comments }); @@ -331,22 +338,19 @@ runs: } } else { // No inline comments, just post the summary + let summaryBody = `## AI Code Review\n\n${reviewData.review_summary}\n\n*No specific line comments generated.*\n\n` + + `---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*`; + + // Add triggered by note if from comment + if (context.eventName === 'issue_comment') { + summaryBody = `*Triggered by @${context.payload.comment.user.login}'s request*\n\n${summaryBody}`; + } + await github.rest.issues.createComment({ issue_number: prNumber, owner: context.repo.owner, repo: context.repo.repo, - body: `## AI Code Review\n\n${reviewData.review_summary}\n\n*No specific line comments generated.*\n\n` + - `---\n*💡 To request a new detailed review, comment \`@continue-detailed-review\`*` - }); - } - - // Add triggered by note if from comment - if (context.eventName === 'issue_comment') { - await github.rest.issues.createComment({ - issue_number: prNumber, - owner: context.repo.owner, - repo: context.repo.repo, - body: `*Inline review triggered by @${context.payload.comment.user.login}*` + body: summaryBody }); }