@@ -34,10 +34,12 @@ class SupportedActions:
3434 add_remove_labels_action_name : str = "add-remove-labels"
3535 pr_size_action_name : str = "add-pr-size-label"
3636 welcome_comment_action_name : str = "add-welcome-comment-set-assignee"
37+ build_push_pr_image_action_name : str = "push-container-on-comment"
3738 supported_actions : set [str ] = {
3839 pr_size_action_name ,
3940 add_remove_labels_action_name ,
4041 welcome_comment_action_name ,
42+ build_push_pr_image_action_name ,
4143 }
4244
4345 def __init__ (self ) -> None :
@@ -58,7 +60,7 @@ def __init__(self) -> None:
5860 def verify_base_config (self ) -> None :
5961 if not self .action or self .action not in self .SupportedActions .supported_actions :
6062 sys .exit (
61- "`ACTION` is not set in workflow or is not supported. "
63+ f" { self . action } is not set in workflow or is not supported. "
6264 f"Supported actions: { self .SupportedActions .supported_actions } "
6365 )
6466
@@ -97,10 +99,9 @@ def __init__(self) -> None:
9799 self .comment_body = os .getenv ("REVIEW_COMMENT_BODY" , "" )
98100 self .last_commit = list (self .pr .get_commits ())[- 1 ]
99101 self .last_commit_sha = self .last_commit .sha
100-
101102 self .verify_labeler_config ()
102103
103- def verify_allowed_user (self ) -> None :
104+ def verify_allowed_user (self ) -> bool :
104105 org : Organization = self .gh_client .get_organization ("opendatahub-io" )
105106 # slug is the team name with replaced special characters,
106107 # all words to lowercase and spaces replace with a -
@@ -109,9 +110,10 @@ def verify_allowed_user(self) -> None:
109110 # check if the user is a member of opendatahub-tests-contributors
110111 membership = team .get_team_membership (member = self .user_login )
111112 LOGGER .info (f"User { self .user_login } is a member of the test contributor team. { membership } " )
113+ return True
112114 except UnknownObjectException :
113115 LOGGER .error (f"User { self .user_login } is not allowed for this action. Exiting." )
114- sys . exit ( 0 )
116+ return False
115117
116118 def verify_labeler_config (self ) -> None :
117119 if self .action == self .SupportedActions .add_remove_labels_action_name and self .event_name in (
@@ -131,9 +133,13 @@ def run_pr_label_action(self) -> None:
131133 if self .action == self .SupportedActions .pr_size_action_name :
132134 self .set_pr_size ()
133135
136+ if self .action == self .SupportedActions .build_push_pr_image_action_name :
137+ if not self .verify_allowed_user ():
138+ sys .exit (1 )
139+
134140 if self .action == self .SupportedActions .add_remove_labels_action_name :
135- self .verify_allowed_user ()
136- self .add_remove_pr_labels ()
141+ if self .verify_allowed_user ():
142+ self .add_remove_pr_labels ()
137143
138144 if self .action == self .SupportedActions .welcome_comment_action_name :
139145 self .add_welcome_comment_set_assignee ()
0 commit comments