Skip to content

Commit

Permalink
Bug 1927210 - Enable git-issue-comment actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bendk committed Nov 5, 2024
1 parent a25704b commit 56f7313
Showing 1 changed file with 38 additions and 55 deletions.
93 changes: 38 additions & 55 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ policy:
tasks:
- $let:
trustDomain: app-services
isPullRequest:
$eval: 'tasks_for[:19] == "github-pull-request" || tasks_for == "github-issue-comment"'
pullRequestAction:
$if: 'tasks_for == "github-pull-request"'
then: ${event.action}
Expand All @@ -24,61 +26,35 @@ tasks:
$let:
# Github events have this stuff in different places
ownerEmail:
$if: 'tasks_for in ["cron", "action"]'
then: '${tasks_for}@noreply.mozilla.org'
else:
$if: 'tasks_for == "github-push"'
then: '${event.pusher.email}'
# Assume Pull Request
else:
$if: 'tasks_for == "github-pull-request"'
then: '${event.pull_request.user.login}@users.noreply.github.com'

$switch:
'tasks_for == "github-push"': '${event.pusher.email}'
isPullRequest: '${event.pull_request.user.login}@users.noreply.github.com'
'tasks_for in ["cron", "action"]': '${tasks_for}@noreply.mozilla.org'
baseRepoUrl:
$if: 'tasks_for == "github-push"'
then: '${event.repository.html_url}'
else:
$if: 'tasks_for == "github-pull-request"'
then: '${event.pull_request.base.repo.html_url}'
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${repository.url}'
$switch:
'tasks_for == "github-push"': '${event.repository.html_url}'
isPullRequest: '${event.pull_request.base.repo.html_url}'
'tasks_for in ["cron", "action"]': '${repository.url}'
repoUrl:
$if: 'tasks_for == "github-push"'
then: '${event.repository.html_url}'
else:
$if: 'tasks_for == "github-pull-request"'
then: '${event.pull_request.head.repo.html_url}'
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${repository.url}'
$switch:
'tasks_for == "github-push"': '${event.repository.html_url}'
isPullRequest: '${event.pull_request.head.repo.html_url}'
'tasks_for in ["cron", "action"]': '${repository.url}'
project:
$if: 'tasks_for == "github-push"'
then: '${event.repository.name}'
else:
$if: 'tasks_for == "github-pull-request"'
then: '${event.pull_request.head.repo.name}'
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${repository.project}'
$switch:
'tasks_for == "github-push"': '${event.repository.name}'
isPullRequest: '${event.pull_request.head.repo.name}'
'tasks_for in ["cron", "action"]': '${repository.project}'
head_branch:
$if: 'tasks_for == "github-pull-request"'
then: ${event.pull_request.head.ref}
else:
$if: 'tasks_for == "github-push"'
then: ${event.ref}
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${push.branch}'
$switch:
'tasks_for == "github-push"': ${event.ref}
isPullRequest: ${event.pull_request.head.ref}
'tasks_for in ["cron", "action"]': '${push.branch}'
head_sha:
$if: 'tasks_for == "github-push"'
then: '${event.after}'
else:
$if: 'tasks_for == "github-pull-request"'
then: '${event.pull_request.head.sha}'
else:
$if: 'tasks_for in ["cron", "action"]'
then: '${push.revision}'
$switch:
'tasks_for == "github-push"': '${event.after}'
isPullRequest: '${event.pull_request.head.sha}'
'tasks_for in ["cron", "action"]': '${push.revision}'
in:
$if: >
tasks_for in ["action", "cron"]
Expand Down Expand Up @@ -112,7 +88,7 @@ tasks:
$merge:
- owner: "${ownerEmail}"
source: '${repoUrl}/raw/${head_sha}/.taskcluster.yml'
- $if: 'tasks_for in ["github-push", "github-pull-request"]'
- $if: 'tasks_for in ["github-push", "github-pull-request", "github-issue-comment"]'
then:
name: "Decision Task"
description: 'The task that creates all of the other tasks in the task graph'
Expand All @@ -130,7 +106,7 @@ tasks:
provisionerId: "app-services-${level}"
workerType: "decision-gcp"
tags:
$if: 'tasks_for in ["github-push", "github-pull-request"]'
$if: 'tasks_for in ["github-push", "github-pull-request", "github-issue-comment']'
then:
kind: decision-task
else:
Expand All @@ -147,7 +123,7 @@ tasks:
# We check for not pull-request instead of level 3 to support `staging-application-services`.
# This is ok as ${project} uniquely identifies the repo within this trust domain, and each
# project only has scopes to its own index namespace, so namespace collisions shouldn't happen.
- $if: 'tasks_for != "github-pull-request"'
- $if: '!isPullRequest'
then:
- $if: 'tasks_for == "github-push"'
then:
Expand All @@ -166,7 +142,7 @@ tasks:
# `https://` is 8 characters so, ${repoUrl[8:]} is the repository without the protocol.
- 'assume:repo:${repoUrl[8:]}:branch:${short_head_branch}'
else:
$if: 'tasks_for == "github-pull-request"'
$if: isPullRequest
then:
- 'assume:repo:github.com/${event.pull_request.base.repo.full_name}:pull-request'
else:
Expand Down Expand Up @@ -226,7 +202,14 @@ tasks:
- bash
- -cx
- $let:
extraArgs: {$if: 'tasks_for == "cron"', then: '${cron.quoted_args}', else: ''}
# Can't use $switch statement here, see https://github.com/json-e/json-e/issues/541
extraArgs:
$if: 'tasks_for == "cron"'
then: '${cron.quoted_args}'
else:
$if: 'tasks_for == "github-issue-comment"'
then: '--target-tasks-method=${event.taskcluster_comment}'
else: ''
in:
$if: 'tasks_for == "action"'
then: >
Expand Down

0 comments on commit 56f7313

Please sign in to comment.