merge ci steps
This commit is contained in:
89
.drone.jsonnet
Normal file
89
.drone.jsonnet
Normal file
@ -0,0 +1,89 @@
|
||||
local image = std.extVar("image");
|
||||
local app_name = std.extVar("app_name");
|
||||
local target_arch = std.extVar("target_arch");
|
||||
|
||||
local flags = " --release --target=" + target_arch;
|
||||
|
||||
local volume(name, path) = {
|
||||
name: name,
|
||||
path: path,
|
||||
};
|
||||
|
||||
local volumes = [
|
||||
volume("cargo", "/usr/local/cargo"),
|
||||
volume("target", "/cache/target"),
|
||||
volume("rustup", "/usr/local/rustup"),
|
||||
];
|
||||
|
||||
local step(name, depends=[], commands=[], env={}) = {
|
||||
name: name,
|
||||
volumes: volumes,
|
||||
image: image,
|
||||
depends_on: depends,
|
||||
commands: commands,
|
||||
environment: env + {
|
||||
CARGO_TARGET_DIR: "/cache/target",
|
||||
APP_NAME: "deploytest",
|
||||
},
|
||||
};
|
||||
|
||||
local temp_volume(name) = {
|
||||
name: name,
|
||||
temp: {},
|
||||
};
|
||||
|
||||
local host_volume(name, path) = {
|
||||
name: name,
|
||||
host: {
|
||||
path: path,
|
||||
},
|
||||
};
|
||||
|
||||
{
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
name: "default",
|
||||
platform: {
|
||||
"os": "linux",
|
||||
"arch": "arm",
|
||||
},
|
||||
|
||||
steps: [
|
||||
step(
|
||||
"validate",
|
||||
commands=["cargo test" + flags],
|
||||
),
|
||||
step(
|
||||
"test",
|
||||
depends=["validate"],
|
||||
commands=["cargo test" + flags],
|
||||
),
|
||||
step(
|
||||
"build",
|
||||
depends=["test"],
|
||||
commands=["cargo build" + flags],
|
||||
),
|
||||
step(
|
||||
"deploy",
|
||||
depends=["build"],
|
||||
commands=["sh scripts/deploy.sh"],
|
||||
env={
|
||||
"TARGET_DIR": "/cache/target/" + target_arch + "/release",
|
||||
"SSH_PRIVATE_KEY": {"from_secret": "ssh_pk_base64"},
|
||||
"SSH_USER": {"from_secret": "SSH_USER"},
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
volumes: [
|
||||
temp_volume("target"),
|
||||
host_volume("cargo", "/home/pi/.cargo"),
|
||||
host_volume("rustup", "/home/pi/.rustup"),
|
||||
],
|
||||
|
||||
// BUG: thid does not add.
|
||||
// environment: {
|
||||
// CARGO_TARGET_DIR: "/cache/target/",
|
||||
// APP_NAME: "deploytest",
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user