Drop drone

main
mat ess 2022-12-22 01:32:35 -05:00
parent d1c1c0693b
commit 0ab4763af2
1 changed files with 8 additions and 22 deletions

View File

@ -1,10 +1,6 @@
local PROD = 'production'; local PROD = 'production';
local STAGE = 'staging'; local STAGE = 'staging';
local NIX = 'nix --sandbox --extra-experimental-features nix-command --extra-experimental-features flakes '; local NIX = 'nix --extra-experimental-features nix-command --extra-experimental-features flakes';
local VOLUMES = [
{ name: 'site', path: '/site' },
{ name: 'cache', path: '/nix/store' },
];
local Secrets(secrets) = { local Secrets(secrets) = {
environment: { environment: {
@ -20,28 +16,19 @@ local WhenProd(prod) = if prod then {
target: { exclude: [PROD] }, target: { exclude: [PROD] },
}; };
local Step(env, name, cmds, extras={}, volumes=VOLUMES) = local Step(env, name, cmds, extras={}) =
local prod = env == PROD; local prod = env == PROD;
{ {
name: name + ' ' + env, name: name + ' ' + env,
image: 'nixos/nix:latest', image: 'nixos/nix:latest',
volumes: volumes, volumes: [
{ name: 'site', path: '/site' },
{ name: 'cache', path: '/nix/store' },
],
commands: cmds, commands: cmds,
when: WhenProd(prod), when: WhenProd(prod),
privileged: true,
} + extras; } + extras;
local BootstrapStep =
Step(STAGE, 'bootrap nix', [
'for file in /nix/store/*; do',
' item=$(basename $file)',
' if [ ! -e /cache/$item ]; then',
' echo "moving $file to cache"',
' cp -r $file /cache/$item',
' fi',
'done',
], volumes=[{ name: 'cache', path: '/cache' }]);
local NixStep(env) = local NixStep(env) =
local prod = env == PROD; local prod = env == PROD;
local output = if prod then '' else ' .#staging-site'; local output = if prod then '' else ' .#staging-site';
@ -69,7 +56,6 @@ local DeployStep(env) =
], ],
steps: [ steps: [
BootstrapStep,
NixStep(STAGE), NixStep(STAGE),
NixStep(PROD), NixStep(PROD),
DeployStep(STAGE), DeployStep(STAGE),