2022-10-20 22:40:22 +00:00
|
|
|
local Volume = { name: 'site', path: '/site' };
|
2022-10-20 23:32:33 +00:00
|
|
|
local WhenProd(prod) = if prod then {
|
|
|
|
event: ['promote'],
|
|
|
|
target: ['production'],
|
|
|
|
} else {
|
|
|
|
target: { exclude: ['production'] },
|
|
|
|
};
|
|
|
|
local NixStep(env) =
|
|
|
|
local prod = env == 'production';
|
|
|
|
local output = if prod then '' else ' .#staging-site';
|
|
|
|
{
|
|
|
|
name: 'nix build ' + env,
|
|
|
|
image: 'nixos/nix',
|
|
|
|
volumes: [Volume],
|
|
|
|
commands: [
|
|
|
|
'$NIX build' + output,
|
|
|
|
'cp -r result/* /site/',
|
|
|
|
],
|
|
|
|
when: WhenProd(prod),
|
|
|
|
};
|
2022-10-20 23:07:18 +00:00
|
|
|
local NetlifyStep(env) =
|
|
|
|
local prod = env == 'production';
|
|
|
|
{
|
|
|
|
name: 'netlify deploy ' + env,
|
|
|
|
image: 'internetmat/drone-netlify',
|
|
|
|
volumes: [Volume],
|
|
|
|
settings: {
|
|
|
|
token: { from_secret: 'netlify_token' },
|
|
|
|
site: { from_secret: 'netlify_site_id' },
|
2022-10-21 01:57:27 +00:00
|
|
|
alias: env,
|
2022-10-20 23:07:18 +00:00
|
|
|
path: '/site',
|
|
|
|
prod: prod,
|
|
|
|
},
|
2022-10-20 23:32:33 +00:00
|
|
|
when: WhenProd(prod),
|
2022-10-20 23:07:18 +00:00
|
|
|
};
|
2022-10-20 22:40:22 +00:00
|
|
|
{
|
|
|
|
kind: 'pipeline',
|
|
|
|
type: 'docker',
|
|
|
|
name: 'default',
|
|
|
|
|
|
|
|
environment: {
|
|
|
|
NIX: 'nix --extra-experimental-features nix-command --extra-experimental-features flakes',
|
|
|
|
},
|
|
|
|
|
|
|
|
volumes: [{ name: 'site', temp: {} }],
|
|
|
|
|
|
|
|
steps: [
|
2022-10-20 23:32:33 +00:00
|
|
|
NixStep('staging'),
|
|
|
|
NixStep('production'),
|
2022-10-20 23:07:18 +00:00
|
|
|
NetlifyStep('staging'),
|
|
|
|
NetlifyStep('production'),
|
2022-10-20 22:40:22 +00:00
|
|
|
],
|
|
|
|
}
|