Meta: Use author username for pull request IRC notifications

Just 'github.actor' may or may not be the actual PR author, but
especially since action runs have to be approved for first-time
contributors, it's been giving us a lot of incorrect results.
This commit is contained in:
Linus Groh 2021-04-30 22:56:46 +02:00
parent 488ee56cf7
commit 4d697855ea
Notes: sideshowbarker 2024-07-18 18:51:29 +09:00

View file

@ -55,6 +55,10 @@ def compute_lines(wrapper):
elif 'pull_request' in event:
# This is a PR.
raw_action = event['action']
pull_request = event['pull_request']
# actor, until here, is whoever caused the action to run -
# if it's a PR we want the author's name in the notification.
actor = pull_request['user']['login']
if raw_action == 'opened':
action = 'opened'
elif raw_action == 'reopened':
@ -65,7 +69,7 @@ def compute_lines(wrapper):
return False
else:
action = '{}(?)'.format(raw_action)
if event['pull_request'].get('draft', True):
if pull_request.get('draft', True):
print("This is a draft PR, so IRC won't be notified.")
print('Note: No rebuild occurs when the PR is "un-drafted"!')
return False
@ -74,8 +78,8 @@ def compute_lines(wrapper):
action=action,
status=status,
run_id=run_id,
title=event['pull_request'].get('title', '???'),
link=event['pull_request'].get('_links', dict()).get('html', dict()).get('href', '???'),
title=pull_request.get('title', '???'),
link=pull_request.get('_links', {}).get('html', {}).get('href', '???'),
)
else:
print('Unrecognized event type?!')