Rework drone config
continuous-integration/drone/push Build is failing Details

main
mat ess 2022-12-21 22:09:21 -05:00
parent 130efc7383
commit 168297aa8f
1 changed files with 34 additions and 36 deletions

View File

@ -1,54 +1,52 @@
local Volume = { name: 'site', path: '/site' }; local PROD = 'production';
local STAGE = 'staging';
local VOLUME = { name: 'site', path: '/site' };
local NIX = 'nix --extra-experimental-features nix-command --extra-experimental-features flakes';
local WhenProd(prod) = if prod then { local WhenProd(prod) = if prod then {
event: ['promote'], event: ['promote'],
target: ['production'], target: [PROD],
} else { } else {
target: { exclude: ['production'] }, target: { exclude: [PROD] },
}; };
local NixStep(env) =
local prod = env == 'production'; local Step(env, name, cmds) =
local output = if prod then '' else ' .#staging-site'; local prod = env == PROD;
{ {
name: 'nix build ' + env, name: name + ' ' + env,
image: 'nixos/nix:latest', image: 'nixos/nix:latest',
volumes: [Volume], volumes: [VOLUME],
commands: [ commands: cmds,
'$NIX build' + output,
'cp -r result/* /site/',
],
when: WhenProd(prod),
};
local NetlifyStep(env) =
local prod = env == 'production';
{
name: 'netlify deploy ' + env,
image: 'internetmat/drone-netlify:latest',
pull: 'always',
volumes: [Volume],
settings: {
token: { from_secret: 'netlify_token' },
site: { from_secret: 'netlify_site_id' },
alias: env,
path: '/site',
prod: prod,
},
when: WhenProd(prod), when: WhenProd(prod),
}; };
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,
]);
{ {
kind: 'pipeline', kind: 'pipeline',
type: 'docker', type: 'docker',
name: 'default', name: 'default',
environment: {
NIX: 'nix --extra-experimental-features nix-command --extra-experimental-features flakes',
},
volumes: [{ name: 'site', temp: {} }], volumes: [{ name: 'site', temp: {} }],
steps: [ steps: [
NixStep('staging'), NixStep(STAGE),
NixStep('production'), NixStep(PROD),
NetlifyStep('staging'), DeployStep(STAGE),
NetlifyStep('production'), DeployStep(PROD),
], ],
} }