Skip to content

Commit

Permalink
Lookup reviewer by email
Browse files Browse the repository at this point in the history
Signed-off-by: Michael D Kinney <[email protected]>
  • Loading branch information
mdkinney committed Jul 15, 2022
1 parent 37d415f commit bc1871e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/AssignReviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
from codeowners import CodeOwners
from git import Git
from github import Github
Hub = Github('${{ secrets.GITHUB_TOKEN }}')
print ('Hub:', Hub)
CurrentReviewers = [x['login'] for x in json.loads (os.environ['REVIEWER_CONTEXT'])]
print ('CurrentReviewers:', CurrentReviewers)
AllReviewers = CodeOwners(open('.github/REVIEWERS').read())
Expand All @@ -64,12 +66,15 @@ jobs:
print ('File:', File, AllReviewers.of(File))
for FileReviewer in AllReviewers.of(File):
FileReviewerLogin = FileReviewer[1].lstrip('@')
if FileReviewerLogin not in CurrentReviewers:
if '@' in FileReviewerLogin:
for User in Hub.search_users(FileReviewerLogin + ' in email'):
if FileReviewerLogin == User.email:
FileReviewerLogin = User.login
break
if FileReviewerLogin not in CurrentReviewers and FileReviewerLogin not in AddReviewers:
AddReviewers.append(FileReviewerLogin)
print ('AddReviewers:', AddReviewers)
if AddReviewers:
Hub = Github('${{ secrets.GITHUB_TOKEN }}')
print ('Hub:', Hub)
HubRepo = Hub.get_repo('${{ github.event.repository.full_name }}')
print ('HubRepo:', HubRepo)
HubPullRequest = HubRepo.get_pull(${{ github.event.pull_request.number }})
Expand Down

0 comments on commit bc1871e

Please sign in to comment.