Add stage and production nix builds
continuous-integration/drone/push Build is failing Details

pull/1/head
mat ess 2022-10-20 19:32:33 -04:00
parent 699337c32e
commit 32e3cb8913
2 changed files with 30 additions and 15 deletions

View File

@ -1,4 +1,23 @@
local Volume = { name: 'site', path: '/site' };
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),
};
local NetlifyStep(env) =
local prod = env == 'production';
{
@ -11,12 +30,7 @@ local NetlifyStep(env) =
path: '/site',
prod: prod,
},
when: if prod then {
event: ['promote'],
target: ['production'],
} else {
target: { exclude: ['production'] },
},
when: WhenProd(prod),
};
{
kind: 'pipeline',
@ -30,15 +44,8 @@ local NetlifyStep(env) =
volumes: [{ name: 'site', temp: {} }],
steps: [
{
name: 'nix build',
image: 'nixos/nix',
volumes: [Volume],
commands: [
'$NIX build',
'cp -r result/* /site/',
],
},
NixStep('staging'),
NixStep('production'),
NetlifyStep('staging'),
NetlifyStep('production'),
],

View File

@ -36,6 +36,14 @@
cp -r public $out
'';
};
packages.staging-site = config.packages.default.overrideAttrs (_: {
buildPhase = ''
optimize-images
zola build --drafts --base_url $DEPLOY_PRIME_URL
# zola's ignored_content setting doesn't work in static/
rm -rf public/image/_favicon.svg
'';
});
devShells.default = with pkgs; mkShell {
packages = [ optimize-images zola ];
shellHook = linkFonts;