From ac3ba4a1a95172384bdb1000992c1ddc86a5bca1 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Fri, 25 Oct 2024 12:33:40 -0400 Subject: [PATCH] required-review: Avoid requesting reviews from bots (#39895) Attempting to request a review from a bot account will likely fail, as bot accounts are not "collaborators". Fortunately a bot account is probably going to look like `@something[bot]`, so we can look for that to exclude them without having to make extra API queries. --- .../changelog/fix-required-review-no-request-review-from-bot | 4 ++++ projects/github-actions/required-review/src/request-review.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 projects/github-actions/required-review/changelog/fix-required-review-no-request-review-from-bot diff --git a/projects/github-actions/required-review/changelog/fix-required-review-no-request-review-from-bot b/projects/github-actions/required-review/changelog/fix-required-review-no-request-review-from-bot new file mode 100644 index 0000000000000..bb2852820990b --- /dev/null +++ b/projects/github-actions/required-review/changelog/fix-required-review-no-request-review-from-bot @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Avoid trying to request reviews from bot accounts. diff --git a/projects/github-actions/required-review/src/request-review.js b/projects/github-actions/required-review/src/request-review.js index f6aa0acb39bb6..c8ebbda971d72 100644 --- a/projects/github-actions/required-review/src/request-review.js +++ b/projects/github-actions/required-review/src/request-review.js @@ -21,7 +21,9 @@ async function requestReviewer( teams ) { const teamReviews = []; for ( const t of teams ) { - if ( t.startsWith( '@' ) ) { + if ( t.startsWith( '@' ) && t.endsWith( '[bot]' ) ) { + core.info( `Skipping ${ t }, appears to be a bot` ); + } else if ( t.startsWith( '@' ) ) { userReviews.push( t.slice( 1 ) ); } else { teamReviews.push( t );