mat.services/.drone.jsonnet

56 lines
1.2 KiB
Plaintext
Raw Normal View History

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,
2022-10-21 03:08:14 +00:00
image: 'nixos/nix:latest',
2022-10-20 23:32:33 +00:00
volumes: [Volume],
commands: [
'$NIX build' + output,
'cp -r result/* /site/',
],
when: WhenProd(prod),
};
local NetlifyStep(env) =
local prod = env == 'production';
{
name: 'netlify deploy ' + env,
2022-10-21 03:08:14 +00:00
image: 'internetmat/drone-netlify:latest',
2022-10-21 03:12:58 +00:00
pull: 'always',
volumes: [Volume],
settings: {
token: { from_secret: 'netlify_token' },
site: { from_secret: 'netlify_site_id' },
2022-10-21 01:57:27 +00:00
alias: env,
path: '/site',
prod: prod,
2022-10-21 04:53:24 +00:00
debug: true,
},
2022-10-20 23:32:33 +00:00
when: WhenProd(prod),
};
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'),
NetlifyStep('staging'),
NetlifyStep('production'),
2022-10-20 22:40:22 +00:00
],
}