Skip to content

Commit 7e8dbfc

Browse files
Copilottrwalke
andauthored
Prevent duplicate bot comments in auto-answer-issues workflow (#5844)
* Initial plan * Add duplicate comment detection to auto-answer-issues workflow Co-authored-by: trwalke <30090357+trwalke@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: trwalke <30090357+trwalke@users.noreply.github.com>
1 parent 05212dd commit 7e8dbfc

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/auto-answer-issues.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ jobs:
8484
const body = ISSUE_BODY || "";
8585
8686
const octokit = new Octokit({ auth: GITHUB_TOKEN });
87+
88+
// Check if the bot has already commented on this issue to avoid duplicate responses.
89+
const comments = await octokit.paginate(octokit.issues.listComments, {
90+
owner: REPO_OWNER,
91+
repo: REPO_NAME,
92+
issue_number: issueNumber,
93+
per_page: 100
94+
});
95+
const botAlreadyCommented = comments.some(
96+
(comment) => comment.user?.login === "github-actions[bot]"
97+
);
98+
if (botAlreadyCommented) {
99+
console.log("Bot has already commented on this issue. Skipping.");
100+
return;
101+
}
102+
87103
const openai = new AzureOpenAI({
88104
apiKey: AZURE_OPENAI_API_KEY,
89105
endpoint: AZURE_OPENAI_ENDPOINT,

0 commit comments

Comments
 (0)