mat.services/.drone.jsonnet

53 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-12-22 03:09:21 +00:00
local PROD = 'production';
local STAGE = 'staging';
local VOLUME = { name: 'site', path: '/site' };
local NIX = 'nix --extra-experimental-features nix-command --extra-experimental-features flakes';
2022-10-20 23:32:33 +00:00
local WhenProd(prod) = if prod then {
event: ['promote'],
2022-12-22 03:09:21 +00:00
target: [PROD],
2022-10-20 23:32:33 +00:00
} else {
2022-12-22 03:09:21 +00:00
target: { exclude: [PROD] },
2022-10-20 23:32:33 +00:00
};
2022-12-22 03:09:21 +00:00
local Step(env, name, cmds) =
local prod = env == PROD;
2022-10-20 23:32:33 +00:00
{
2022-12-22 03:09:21 +00:00
name: name + ' ' + env,
2022-10-21 03:08:14 +00:00
image: 'nixos/nix:latest',
2022-12-22 03:09:21 +00:00
volumes: [VOLUME],
commands: cmds,
2022-10-20 23:32:33 +00:00
when: WhenProd(prod),
};
2022-12-22 03:09:21 +00:00
local NixStep(env) =
local prod = env == PROD;
local output = if prod then '' else ' .#staging-site';
Step(env, 'nix build', [
NIX + ' build' + output,
'cp -r result/* /site/',
]);
local DeployStep(env) =
local prod = env == PROD;
local options = if prod then '--prod' else '--alias staging';
Step(env, 'netlify deploy', [
NIX + ' profile install netlify-cli',
'netlify deploy -d /site ' + options,
]);
2022-10-20 22:40:22 +00:00
{
kind: 'pipeline',
type: 'docker',
name: 'default',
volumes: [{ name: 'site', temp: {} }],
steps: [
2022-12-22 03:09:21 +00:00
NixStep(STAGE),
NixStep(PROD),
DeployStep(STAGE),
DeployStep(PROD),
2022-10-20 22:40:22 +00:00
],
}