GitHub event data as JSON

This commit is contained in:
Simon Sapin 2018-08-30 15:18:54 +02:00
parent adb4f10d80
commit d918ccd24b
2 changed files with 15 additions and 12 deletions

View file

@ -26,10 +26,7 @@ tasks:
taskclusterProxy: true taskclusterProxy: true
env: env:
DECISION_TASK_ID: {$eval: as_slugid("decision_task")} DECISION_TASK_ID: {$eval: as_slugid("decision_task")}
DECISION_TASK_OWNER: ${event.pusher.name}@users.noreply.github.com GITHUB_EVENT: {$json: event}
DECISION_TASK_SOURCE: ${event.compare}
DECISION_TASK_CLONE_URL: ${event.repository.clone_url}
DECISION_TASK_COMMIT_SHA: ${event.after}
command: command:
- /bin/bash - /bin/bash
- '--login' - '--login'

View file

@ -1,9 +1,15 @@
# coding: utf8 # coding: utf8
import os import os
import datetime import json
import pprint
import taskcluster import taskcluster
event = json.loads(environ["GITHUB_EVENT"])
print("GitHub event:")
pprint.pprint(event)
print("")
task_id = taskcluster.slugId() task_id = taskcluster.slugId()
payload = { payload = {
"taskGroupId": os.environ["DECISION_TASK_ID"], "taskGroupId": os.environ["DECISION_TASK_ID"],
@ -16,8 +22,8 @@ payload = {
"metadata": { "metadata": {
"name": "Taskcluster experiments for Servo: Child task", "name": "Taskcluster experiments for Servo: Child task",
"description": "", "description": "",
"owner": os.environ["DECISION_TASK_OWNER"], "owner": event["pusher"]["name"] + "@users.noreply.github.com",
"source": os.environ["DECISION_TASK_SOURCE"], "source": event["compare"],
}, },
"payload": { "payload": {
"maxRunTime": 600, "maxRunTime": 600,
@ -27,11 +33,11 @@ payload = {
"--login", "--login",
"-c", "-c",
""" """
git clone %(DECISION_TASK_CLONE_URL)s repo && git clone {event[repository][clone_url]} repo &&
cd repo && cd repo &&
git checkout %(DECISION_TASK_COMMIT_SHA)s && git checkout {event[after]} &&
./child-task.sh ./child-task.sh
""" % os.environ, """.format(event=event),
], ],
"artifacts": { "artifacts": {
"public/executable.gz": { "public/executable.gz": {
@ -44,5 +50,5 @@ payload = {
} }
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/features#feature-taskclusterproxy # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/features#feature-taskclusterproxy
queue = taskcluster.Queue(options={"baseUrl": "http://taskcluster/queue/v1/"}) queue = taskcluster.Queue(options={"baseUrl": "http://taskcluster/queue/v1/"})
result = queue.createTask(task_id, payload) queue.createTask(task_id, payload)
print("task %s created…? %r" % (task_id, result)) print("new task scheduled: " % task_id)