.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Giles Bradshaw 2020-04-26 13:59:31 +01:00
parent 601d87537a
commit e82b1be08b
1 changed files with 47 additions and 9 deletions

View File

@ -1,9 +1,48 @@
load("@this//:from-secret.star", "fromSecret") def fromSecret(name):
load("@this//:map.star", "map") return {
load("@this//:print-secrets.star", "printSecrets") "from_secret": name
load("@this//:environment.star", "environment") }
load("@this//:print-secrets.star", "export") def environment(env):
return dict(
[(x.replace("-", "_").upper(), fromSecret(x)) for x in env]
)
def map(fn, l):
return [fn(x) for x in l]
def secretToEnvironment(secret):
return secret.replace("-", "_").upper()
def echo(secret):
return 'echo "export {environment}=${environment}" >> ***filename*** # {secret}'.format(
secret = secret,
environment = secret.replace("-", "_").upper(),
)
def echoSecret(secret):
return 'echo "export {environment}=???" >> ***filename*** # {secret}'.format(
secret = secret,
environment = secret.replace("-", "_").upper()
)
def export(secret):
return "export {toCaps}=${toCaps}".format(
toCaps = secretToEnvironment(secret),
)
def printSecrets(filename, env, secretEnv):
return {
"name": "print secrets",
"image": "appleboy/drone-ssh",
"environment": environment(env),
"settings": {
"envs": [x.replace("-", "_") for x in env ],
"host": fromSecret("ssh-host"),
"port": fromSecret("ssh-port"),
"username": fromSecret("ssh-user"),
"password": fromSecret("ssh-password"),
"script": [x.replace("***filename***", filename) for x in [
"rm -f env-stack",
] + map(echo, env)
+ map(echoSecret, secretEnv)]
}
}
def wait(delay, name): def wait(delay, name):
return { return {
"name": name, "name": name,
@ -136,7 +175,7 @@ def deploy(
"docker network prune -f", "docker network prune -f",
"cd {folder}".format(folder=folder), "cd {folder}".format(folder=folder),
"docker stack rm gitea", "docker stack rm gitea",
"sleep 30", "sleep 60",
"docker stack deploy -c {filename} gitea".format(filename = filename), "docker stack deploy -c {filename} gitea".format(filename = filename),
] ]
} }
@ -210,16 +249,15 @@ def main(ctx):
#build("ngrok-gitea"), #build("ngrok-gitea"),
#build("letsencrypt-nginx"), #build("letsencrypt-nginx"),
#buildHome(), #buildHome(),
build("drone-starlark"),
#buildNginx("blog"), #buildNginx("blog"),
#buildNginx("drone"), #buildNginx("drone"),
#buildNginx("git"), #buildNginx("git"),
#buildNginx("remote"), #buildNginx("remote"),
#buildNginx("chat"), #buildNginx("chat"),
scp("/home/giles/gitea-drone-stack"), scp("~/gitea-drone-stack"),
deploy( deploy(
"docker-compose-home.yml", "docker-compose-home.yml",
"/home/giles/gitea-drone-stack", "~/gitea-drone-stack",
), ),
], ],
[], [],