@@ -163,11 +163,11 @@ def action_builder(parameters, graph_config, decision_task_id):
163163 actionPerm = "generic" if generic else cb_name
164164
165165 # gather up the common decision-task-supplied data for this action
166- repo_param = "head_repository"
167166 repository = {
168- "url" : parameters [repo_param ],
167+ "url" : parameters ["head_repository" ],
169168 "project" : parameters ["project" ],
170169 "level" : parameters ["level" ],
170+ "base_url" : parameters ["base_repository" ],
171171 }
172172
173173 revision = parameters ["head_rev" ]
@@ -179,6 +179,9 @@ def action_builder(parameters, graph_config, decision_task_id):
179179 branch = parameters .get ("head_ref" )
180180 if branch :
181181 push ["branch" ] = branch
182+ base_branch = parameters .get ("base_ref" )
183+ if base_branch and branch != base_branch :
184+ push ["base_branch" ] = base_branch
182185
183186 action = {
184187 "name" : name ,
@@ -213,11 +216,16 @@ def action_builder(parameters, graph_config, decision_task_id):
213216 if "/" in actionPerm :
214217 raise Exception ("`/` is not allowed in action names; use `-`" )
215218
219+ if parameters ["tasks_for" ].startswith ("github-pull-request" ):
220+ hookId = f"in-tree-pr-action-{ level } -{ actionPerm } /{ tcyml_hash } "
221+ else :
222+ hookId = f"in-tree-action-{ level } -{ actionPerm } /{ tcyml_hash } "
223+
216224 rv .update (
217225 {
218226 "kind" : "hook" ,
219227 "hookGroupId" : f"project-{ trustDomain } " ,
220- "hookId" : f"in-tree-action- { level } - { actionPerm } / { tcyml_hash } " ,
228+ "hookId" : hookId ,
221229 "hookPayload" : {
222230 # provide the decision-task parameters as context for triggerHook
223231 "decision" : {
@@ -293,16 +301,20 @@ def sanity_check_task_scope(callback, parameters, graph_config):
293301
294302 actionPerm = "generic" if action .generic else action .cb_name
295303
296- repo_param = "head_repository"
297- raw_url = parameters [repo_param ]
304+ raw_url = parameters ["base_repository" ]
298305 parsed_url = parse (raw_url )
299- expected_scope = f"assume:{ parsed_url .taskcluster_role_prefix } :action:{ actionPerm } "
306+ action_scope = f"assume:{ parsed_url .taskcluster_role_prefix } :action:{ actionPerm } "
307+ pr_action_scope = (
308+ f"assume:{ parsed_url .taskcluster_role_prefix } :pr-action:{ actionPerm } "
309+ )
300310
301311 # the scope should appear literally; no need for a satisfaction check. The use of
302312 # get_current_scopes here calls the auth service through the Taskcluster Proxy, giving
303313 # the precise scopes available to this task.
304- if expected_scope not in taskcluster .get_current_scopes ():
305- raise ValueError (f"Expected task scope { expected_scope } for this action" )
314+ if not set ((action_scope , pr_action_scope )) & set (taskcluster .get_current_scopes ()):
315+ raise ValueError (
316+ f"Expected task scope { action_scope } or { pr_action_scope } for this action"
317+ )
306318
307319
308320def trigger_action_callback (
0 commit comments