Skip to content

Commit 5815d61

Browse files
committed
exclude jetify bot, skip if it's an internally created pr
1 parent 06a6d7f commit 5815d61

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/random-reviewer-assignment.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
with:
2020
script: |
2121
const TRIAGE_USERNAME = 'Lagoja';
22+
const EXCLUDE_USERNAMES = ['jetpack-io-bot'];
2223
2324
try {
2425
const authenticatedUser = await github.rest.users.getAuthenticated();
@@ -31,19 +32,28 @@ jobs:
3132
const prAuthor = context.payload.pull_request.user.login.toLowerCase();
3233
const prAuthorId = context.payload.pull_request.user.id;
3334
const authenticatedUserLower = authenticatedUser.data.login.toLowerCase();
35+
36+
// If the PR author is already a member of the team, we can skip random assignment
37+
const isPrAuthorInTeam = teamMembers.data.some(member =>
38+
member.login.toLowerCase() === prAuthor && member.id === prAuthorId
39+
);
40+
41+
if (isPrAuthorInTeam) {
42+
console.log(`PR author ${prAuthor} is already a team member, skipping random assignment.`);
43+
return;
44+
}
3445
3546
// Get eligible reviewers (excluding PR author, authenticated user, and lagoja)
3647
const eligibleReviewers = teamMembers.data
3748
.filter(member => {
3849
const loginLower = member.login.toLowerCase();
3950
40-
// Exclude PR author by both ID and username
41-
const isNotAuthor = (prAuthorId && member.id !== prAuthorId) && loginLower !== prAuthor;
4251
// Exclude authenticated user
4352
const isNotAuthenticatedUser = member.id !== authenticatedUser.data.id;
4453
const isNotTriage = loginLower !== TRIAGE_USERNAME.toLowerCase();
45-
46-
return isNotAuthor && isNotAuthenticatedUser && isNotTriage;
54+
const isNotExcludedUsername = !EXCLUDE_USERNAMES.includes(loginLower);
55+
56+
return isNotAuthenticatedUser && isNotTriage && isNotExcludedUsername;
4757
})
4858
.map(member => member.login);
4959

0 commit comments

Comments
 (0)