2020-04-24 10:29:25 +00:00
|
|
|
def fromSecret(name):
|
|
|
|
return {
|
|
|
|
"from_secret": name
|
|
|
|
}
|
2020-04-24 11:50:26 +00:00
|
|
|
dev environment(env):
|
|
|
|
value={}
|
|
|
|
return value.update(x.replace("-", "_").upper(), fromSecret(x)) for x in env
|
|
|
|
|
2020-04-24 11:42:31 +00:00
|
|
|
def printSecrets(env):
|
2020-04-24 10:29:25 +00:00
|
|
|
return {
|
|
|
|
"name": "printenv",
|
|
|
|
"image": "appleboy/drone-ssh",
|
2020-04-24 11:50:26 +00:00
|
|
|
"environment": environment(env),
|
2020-04-24 10:29:25 +00:00
|
|
|
"settings": {
|
2020-04-24 11:42:31 +00:00
|
|
|
"envs": [x.replace("-", "_") for x in env],
|
2020-04-24 10:29:25 +00:00
|
|
|
"host": fromSecret("ssh-host"),
|
|
|
|
"port": fromSecret("ssh-port"),
|
|
|
|
"username": fromSecret("ssh-user"),
|
|
|
|
"password": fromSecret("ssh-password"),
|
|
|
|
"script": [
|
|
|
|
"echo SSH_HOST=$SSH_HOST > env-stack",
|
|
|
|
"echo SSH_PORT=$SSH_PORT >> env-stack",
|
|
|
|
"echo LOCAL_DOCKER_REGISTRY=$LOCAL_DOCKER_REGISTRY >> env-stack",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2020-04-24 10:10:50 +00:00
|
|
|
def steps(name):
|
2020-04-24 10:07:57 +00:00
|
|
|
return {
|
|
|
|
"kind": "pipeline",
|
2020-04-24 10:10:50 +00:00
|
|
|
"name": name,
|
2020-04-24 10:12:00 +00:00
|
|
|
"clone": {
|
2020-04-24 10:13:30 +00:00
|
|
|
"disable": True,
|
2020-04-24 10:12:00 +00:00
|
|
|
},
|
2020-04-24 10:07:57 +00:00
|
|
|
"steps": [
|
2020-04-24 11:42:31 +00:00
|
|
|
printSecrets([
|
|
|
|
"local-docker-registry",
|
|
|
|
"ssh-host",
|
|
|
|
"ssh-user",
|
|
|
|
"ssh-port",
|
|
|
|
]),
|
2020-04-24 10:07:57 +00:00
|
|
|
{
|
|
|
|
"name": "build",
|
|
|
|
"image": "alpine",
|
|
|
|
"commands": [
|
|
|
|
"echo hello 'star lark'",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|
2020-04-24 06:58:20 +00:00
|
|
|
|
2020-04-24 06:32:20 +00:00
|
|
|
def main(ctx):
|
2020-04-24 10:10:50 +00:00
|
|
|
return [
|
|
|
|
steps('first'),
|
|
|
|
steps('second'),
|
|
|
|
]
|
2020-04-24 09:56:09 +00:00
|
|
|
|