Skip to content

Commit 7c5b7d4

Browse files
authored
fix(init): properly support github-release variables in .tc.yml template (#449)
1 parent a59cae8 commit 7c5b7d4

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

template/{{cookiecutter.project_name}}/taskcluster.github.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,48 +16,53 @@ tasks:
1616
ownerEmail:
1717
$switch:
1818
'tasks_for == "github-push"': '${event.pusher.email}'
19+
'tasks_for == "github-release"': '${event.sender.login}@users.noreply.github.com'
1920
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.user.login}@users.noreply.github.com'
2021
'tasks_for in ["cron", "action"]': '${tasks_for}@noreply.mozilla.org'
2122
baseRepoUrl:
2223
$switch:
23-
'tasks_for == "github-push"': '${event.repository.html_url}'
2424
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.repo.html_url}'
2525
'tasks_for in ["cron", "action"]': '${repository.url}'
26+
$default: '${event.repository.html_url}'
2627
repoUrl:
2728
$switch:
28-
'tasks_for == "github-push"': '${event.repository.html_url}'
2929
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.html_url}'
3030
'tasks_for in ["cron", "action"]': '${repository.url}'
31+
$default: '${event.repository.html_url}'
3132
project:
3233
$switch:
33-
'tasks_for == "github-push"': '${event.repository.name}'
34+
'tasks_for in ["github-push", "github-release"]': '${event.repository.name}'
3435
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.repo.name}'
3536
'tasks_for in ["cron", "action"]': '${repository.project}'
3637
head_branch:
3738
$switch:
3839
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref}
3940
'tasks_for == "github-push"': ${event.ref}
4041
'tasks_for == "github-release"': '${event.release.target_commitish}'
41-
'tasks_for in ["action", "cron"]': '${push.branch}'
42+
'tasks_for in ["cron", "action"]': '${push.branch}'
4243
base_ref:
4344
$switch:
4445
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.base.ref}
4546
'tasks_for == "github-push" && event.base_ref': ${event.base_ref}
4647
'tasks_for == "github-push"': ${event.ref}
48+
'tasks_for == "github-release"': ${event.release.tag_name}
4749
'tasks_for in ["cron", "action"]': '${push.branch}'
4850
head_ref:
4951
$switch:
5052
'tasks_for[:19] == "github-pull-request"': ${event.pull_request.head.ref}
5153
'tasks_for == "github-push"': ${event.ref}
54+
'tasks_for == "github-release"': ${event.release.tag_name}
5255
'tasks_for in ["cron", "action"]': '${push.branch}'
5356
base_sha:
5457
$switch:
5558
'tasks_for == "github-push"': '${event.before}'
59+
'tasks_for == "github-release"': '${event.release.target_commitish}'
5660
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.base.sha}'
5761
'tasks_for in ["cron", "action"]': '${push.revision}'
5862
head_sha:
5963
$switch:
6064
'tasks_for == "github-push"': '${event.after}'
65+
'tasks_for == "github-release"': '${event.release.tag_name}'
6166
'tasks_for[:19] == "github-pull-request"': '${event.pull_request.head.sha}'
6267
'tasks_for in ["cron", "action"]': '${push.revision}'
6368
ownTaskId:
@@ -68,18 +73,24 @@ tasks:
6873
$switch:
6974
'tasks_for[:19] == "github-pull-request"': ${event.action}
7075
$default: 'UNDEFINED'
76+
releaseAction:
77+
$if: 'tasks_for == "github-release"'
78+
then: ${event.action}
79+
else: 'UNDEFINED'
7180
isPullRequest:
7281
$eval: 'tasks_for[:19] == "github-pull-request"'
7382
in:
7483
$let:
7584
short_base_ref:
76-
$if: 'base_ref[:11] == "refs/heads/"'
77-
then: {$eval: 'base_ref[11:]'}
78-
else: ${base_ref}
85+
$switch:
86+
'base_ref[:10] == "refs/tags/"': '${base_ref[10:]}'
87+
'base_ref[:11] == "refs/heads/"': '${$base_ref[11:]}'
88+
$default: '${base_ref}'
7989
short_head_ref:
80-
$if: 'head_ref[:11] == "refs/heads/"'
81-
then: {$eval: 'head_ref[11:]'}
82-
else: ${head_ref}
90+
$switch:
91+
'head_ref[:10] == "refs/tags/"': '${head_ref[10:]}'
92+
'head_ref[:11] == "refs/heads/"': '${head_ref[11:]}'
93+
$default: '${head_ref}'
8394
in:
8495
$if: >
8596
tasks_for in ["action", "cron"]

0 commit comments

Comments
 (0)