portainer/.drone-home.jsonnet

142 lines
2.5 KiB
Plaintext
Raw Normal View History

2020-07-28 14:44:13 +00:00
local util = {
fromSecret(secret): {
from_secret: secret,
},
2020-07-28 15:01:03 +00:00
printEnv(file, env): function(step) step {
environment +: {
[std.asciiHigher(env)]: util.fromSecret(
std.asciiLower(
std.strReplace(
env,
'_',
'-',
),
),
),
},
settings +: {
envs +: [
std.asciiLower(env),
],
script +: [
'echo "export %(environment)=\'$${%(environment)s}\'" >> %(file) # %(secret)s' % {
environment: std.asciiHigher(env),
file: file,
secret: std.asciiLower(
std.strReplace(
env,
'_',
'-',
),
),
},
],
},
},
2020-07-28 14:44:13 +00:00
};
2020-07-28 13:09:17 +00:00
local images = {
docker: {
2020-07-28 14:32:32 +00:00
name: 'docker',
2020-07-28 13:09:17 +00:00
image: 'docker:dind',
},
2020-07-28 14:32:32 +00:00
scp(target): {
name: 'scp',
image: 'appleboy/drone-scp',
settings: {
host: {
from_secret: 'ssh-host',
},
username: {
from_secret: 'ssh-user',
},
password: {
from_secret: 'ssh-password',
},
port: {
from_secret: 'ssh-port',
},
command_timeout: '2m',
target: target,
source: [
'.',
],
},
},
2020-07-28 14:44:13 +00:00
ssh: {
image: 'appleboy/drone-ssh',
settings: {
host: util.fromSecret("ssh-host"),
port: util.fromSecret("ssh-port"),
username: util.fromSecret("ssh-user"),
password: util.fromSecret("ssh-password"),
script: [],
},
},
2020-07-28 14:35:58 +00:00
wait(delay): {
image: 'alpine',
name: 'wait',
commands: [
'sleep %s' % delay,
],
}
2020-07-28 13:09:17 +00:00
};
2020-07-28 13:03:09 +00:00
[
{
kind: 'pipeline',
type: 'docker',
name: 'build',
clone: {
disable: false,
depth: 0,
},
services: [
images.docker {
privileged: true,
volumes: [
{
name: 'dockersock',
path: '/var/run',
},
{
name: 'ca',
path: '/etc/docker/certs.d',
},
],
},
],
volumes: [
{
name: 'dockersock',
temp: {},
},
{
name: 'ca',
host: {
path: '/etc/docker/certs.d',
},
},
{
name: 'ssh',
host: {
path: '/home/giles/.ssh'
},
},
],
2020-07-28 14:32:32 +00:00
steps:[
2020-07-28 14:35:58 +00:00
images.scp(
'/stack/root'
),
images.wait(15),
2020-07-28 15:01:03 +00:00
images.printEnv(
'afile',
'ssh_host',
)(
images.ssh {
name: 'will print ssh-host',
},
)
2020-07-28 14:32:32 +00:00
],
2020-07-28 13:03:09 +00:00
}
]