Skip to content

Commit

Permalink
feat: determine what team the reviewer is on
Browse files Browse the repository at this point in the history
  • Loading branch information
devindford committed Aug 6, 2024
1 parent 28c3254 commit 18d7aac
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/codeowner_review_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ jobs:
)];
console.log('Team slugs:', teamSlugs);
async function checkTeamMembership(teamSlug) {
try {
const { data: teamMembers } = await github.rest.teams.listMembersInOrg({
org: org,
team_slug: teamSlug,
});
return teamMembers.some(member => member.login === reviewer);
} catch (error) {
console.error(`Error checking membership for team ${teamSlug}: ${error}`);
return false;
}
}
for (const teamSlug of teamSlugs) {
if (await checkTeamMembership(teamSlug)) {
console.log(`${reviewer} is a member of the required team ${teamSlug}.`);
return;
}
}
// Function to check if a file matches a pattern
const matchesPattern = (file, pattern) => {
Expand Down Expand Up @@ -89,7 +109,7 @@ jobs:
// Get relevant code owners for the changed files
const relevantOwners = new Set();
const defaultOwner = codeownersRules.find(rule => rule.pattern === '*')?.owners[0];
console.log(defaultOwner)
files.forEach(file => {
let fileOwners = new Set();
let hasSpecificOwner = false;
Expand Down

0 comments on commit 18d7aac

Please sign in to comment.