Skip to content

Commit

Permalink
bcr-pr-reviewer: Avoid spamming module maintainers (#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy authored Jul 12, 2024
1 parent aa52cef commit ecb81a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions actions/bcr-pr-reviewer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ async function notifyMaintainers(octokit, owner, repo, prNumber, maintainersMap)

// Notify maintainers based on grouped module lists
const prAuthor = context.payload.pull_request.user.login;

// If there are too many maintainers, it's likely to be an accidental change that will spam too many people.
if (moduleListToMaintainers.size > 10) {
console.log(`Skipping notifying maintainers as there are too many maintainers: ${moduleListToMaintainers.size}`);
// Notify the PR author that too many modules are modified
const commentBody = `Hello @${prAuthor}, too many modules have been updated in this PR. If this is intended, please consider breaking it down into multiple PRs.`;
await postComment(octokit, owner, repo, prNumber, commentBody);
return;
}

for (const [modulesList, maintainers] of moduleListToMaintainers.entries()) {
// Skip notifying the PR author if they are one of the module maintainers
const maintainersCopy = new Set(maintainers);
Expand Down

0 comments on commit ecb81a9

Please sign in to comment.