This repository has been archived on 2020-08-11. You can view files and clone it, but cannot push or open issues or pull requests.
stack/drone-starlark/repos/deploy.star

35 lines
925 B
Plaintext
Raw Normal View History

2020-04-26 17:06:31 +00:00
load("@this//:from-secret.star", "fromSecret")
load("@this//:map.star", "map")
load("@this//:environment.star", "environment")
load("@this//:export.star", "export")
def deploy(
filename,
2020-04-27 22:48:48 +00:00
name,
2020-04-26 17:06:31 +00:00
folder,
2020-04-28 08:27:15 +00:00
secrets,
2020-04-26 17:06:31 +00:00
):
2020-04-27 20:52:58 +00:00
return {
2020-04-26 17:06:31 +00:00
"name": "deploy",
"image": "appleboy/drone-ssh",
2020-04-28 08:27:15 +00:00
"environment": environment(secrets),
2020-04-26 17:06:31 +00:00
"settings": {
2020-04-28 08:27:15 +00:00
"envs": [x.replace("-", "_") for x in secrets ],
2020-04-26 17:06:31 +00:00
"host": fromSecret("ssh-host"),
"port": fromSecret("ssh-port"),
"username": fromSecret("ssh-root-user"),
"password": fromSecret("ssh-root-password"),
"script": [
"set -e"
] +
2020-04-28 08:27:15 +00:00
map(export, secrets) +
2020-04-26 17:06:31 +00:00
[
"docker network prune -f",
"cd {folder}".format(folder=folder),
2020-04-27 22:48:48 +00:00
"docker stack rm {name}".format(name = name),
2020-04-26 17:06:31 +00:00
"sleep 30",
2020-04-27 22:48:48 +00:00
"docker stack deploy -c {filename} {name}".format(name= name, filename = filename),
2020-04-26 17:06:31 +00:00
]
}
}