def fromSecret(name): return { "from_secret": name } def environment(env): return dict( [(x.replace("-", "_").upper(), fromSecret(x)) for x in env] ) def map(fn, l): [fn(x) for x in l] def identity(x): x def printSecrets(env): envv = map(identity, env) return { "name": "print secrets", "image": "appleboy/drone-ssh", "environment": environment(env), "settings": { "envs": [x.replace("-", "_") for x in envv ], "host": fromSecret("ssh-host"), "port": fromSecret("ssh-port"), "username": fromSecret("ssh-user"), "password": fromSecret("ssh-password"), "script": [ "echo $(($(date +%s%N)/1000000))", "echo SSH_HOST=$SSH_HOST > env-stack", "sleep 5", "echo SSH_PORT=$SSH_PORT >> env-stack", "echo LOCAL_DOCKER_REGISTRY=$LOCAL_DOCKER_REGISTRY >> env-stack", "echo $(($(date +%s%N)/1000000))", "echo $(($(date +%s%N)/1000000)) >> env-stack", ] } } def steps(name, dependsOn): return { "kind": "pipeline", "name": name, "depends_on": dependsOn, "steps": [ printSecrets([ "local-docker-registry", "ssh-host", "ssh-user", "ssh-port", ]), { "name": "build", "image": "alpine", "commands": [ "echo hello 'star lark'", ], }, ], } def main(ctx): return [ steps('first', []), steps('second', ['first']), ]