@@ -290,6 +290,11 @@ def trigger_enabled(policy, trigger):
290290 return trigger in set (enabled or [])
291291
292292
293+ def event_trigger_key (event_name , payload ):
294+ action = str (payload .get ("action" ) or "" ).strip ()
295+ return "{}.{}" .format (event_name , action ) if action else event_name
296+
297+
293298def build_task_from_event (event_name , delivery_id , payload , policy ):
294299 repository = payload .get ("repository" ) or {}
295300 installation = payload .get ("installation" ) or {}
@@ -315,10 +320,12 @@ def build_task_from_event(event_name, delivery_id, payload, policy):
315320 if event_name == "issue_comment" :
316321 issue = payload .get ("issue" ) or {}
317322 comment = payload .get ("comment" ) or {}
323+ if payload .get ("action" ) != "created" :
324+ return ignored (base , "unsupported_issue_comment_action" )
318325 if not mentioned (comment .get ("body" ), policy ):
319326 return ignored (base , "issue_comment_without_mention" )
320- if not trigger_enabled (policy , "issue_mention " ):
321- return ignored (base , "issue_mention_not_enabled " )
327+ if not trigger_enabled (policy , "issue_comment.created " ):
328+ return ignored (base , "issue_comment_not_enabled " )
322329 if issue .get ("pull_request" ):
323330 base .update (
324331 {
@@ -352,9 +359,11 @@ def build_task_from_event(event_name, delivery_id, payload, policy):
352359 if event_name == "pull_request_review_comment" :
353360 comment = payload .get ("comment" ) or {}
354361 pull_request = payload .get ("pull_request" ) or {}
362+ if payload .get ("action" ) != "created" :
363+ return ignored (base , "unsupported_pr_review_comment_action" )
355364 if not mentioned (comment .get ("body" ), policy ):
356365 return ignored (base , "pr_review_comment_without_mention" )
357- if not trigger_enabled (policy , "pr_review_comment " ):
366+ if not trigger_enabled (policy , "pull_request_review_comment.created " ):
358367 return ignored (base , "pr_review_comment_not_enabled" )
359368 base .update (
360369 {
@@ -380,13 +389,13 @@ def build_task_from_event(event_name, delivery_id, payload, policy):
380389 action = payload .get ("action" )
381390 if action not in ("assigned" , "labeled" ):
382391 return ignored (base , "unsupported_issue_action" )
383- if action == "assigned" and not trigger_enabled (policy , "issue_assigned " ):
392+ if action == "assigned" and not trigger_enabled (policy , "issues.assigned " ):
384393 return ignored (base , "issue_assigned_not_enabled" )
385394 if action == "assigned" and not issue_assigned_to_bot (issue , policy ):
386395 return ignored (base , "issue_assigned_to_unmanaged_user" )
387396 if action == "labeled" and not labels_include_trigger (issue .get ("labels" ), policy ):
388397 return ignored (base , "issue_label_not_enabled" )
389- if action == "labeled" and not trigger_enabled (policy , "issue_label " ):
398+ if action == "labeled" and not trigger_enabled (policy , "issues.labeled " ):
390399 return ignored (base , "issue_label_not_enabled" )
391400 base .update (
392401 {
@@ -532,6 +541,21 @@ def route_delivery(event_name, delivery_id, payload, debug):
532541 "reason" : "no_policy_for_installation_repo" ,
533542 }
534543
544+ trigger = event_trigger_key (event_name , payload )
545+ if not trigger_enabled (policy , trigger ):
546+ delivery ["state" ] = "ignored"
547+ delivery ["routing_result" ] = "trigger_not_enabled"
548+ delivery ["installation_id" ] = installation_id or delivery .get ("installation_id" )
549+ delivery ["repository_id" ] = repo_id or delivery .get ("repository_id" )
550+ write_json_atomic (delivery_file , delivery )
551+ return {
552+ "ok" : True ,
553+ "action" : "ignored" ,
554+ "delivery_id" : delivery_id ,
555+ "reason" : "trigger_not_enabled" ,
556+ "trigger" : trigger ,
557+ }
558+
535559 task = build_task_from_event (event_name , delivery_id , payload , policy )
536560 task ["policy_snapshot" ] = {
537561 "enabled_triggers" : policy .get ("enabled_triggers" ) or [],
0 commit comments