This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dispatchfile
72 lines (66 loc) · 2.39 KB
/
Dispatchfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!mesosphere/dispatch-starlark:v0.2-test.2
# vi:syntax=python
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "dindTask")
load("github.com/mesosphere/dispatch-catalog/starlark/stable/[email protected]", "gitResource", "secretVar", "pullRequest", "push")
git = gitResource("git")
dindTask("build", inputs=[ git ], outputs=[ git ], steps=[
k8s.corev1.Container(
name="build",
workingDir="/workspace/{}".format(git),
command=[
"/bin/sh", "-c",
"""
curl -Lo /usr/bin/dispatch https://d2iq-dispatch.s3.amazonaws.com/dispatch_linux_1.1.0-beta1
chmod +x /usr/bin/dispatch
make build
"""
],
env=[
k8s.corev1.EnvVar(name="SCM_TOKEN", valueFrom=secretVar("scmtoken", "password")),
k8s.corev1.EnvVar(name="SCM_USERNAME", valueFrom=secretVar("scmtoken", "username")),
]
), k8s.corev1.Container(
name="stash-output",
image="debian:buster",
workingDir="/workspace/{}".format(git),
command=[
"/bin/bash", "-c", "cp -r /workspace/{src}/. /workspace/output/{src}/".format(src=git)
]
)
])
task("post-merge-updates",
deps=["build"],
inputs=[git],
steps=[
k8s.corev1.Container(
name="commit-image-digest",
image="alpine/git",
workingDir="/workspace/{}".format(git),
command=[
"sh", "-c",
"""
git config user.name CI
git config user.email [email protected]
git add docs/
git diff --cached --exit-code || git commit -m 'chart: bump docs'
"""
]
),
k8s.corev1.Container(
name="push-new-commits",
image="alpine/git",
workingDir="/workspace/{}".format(git),
command=[
"sh", "-c",
"""
git checkout -b $(context.git.branch)
git fetch origin $(context.git.branch)
git diff --exit-code origin/$(context.git.branch) || git push origin $(context.git.branch)
"""
]
)
]
)
action(tasks=["build"], on=pullRequest())
action(tasks=["build"], on=pullRequest(chatops=["build"]))
action(tasks=["post-merge-updates"], on=push(branches=["master"], paths=[ "!docs/*" ]))