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

View File

@ -36,6 +36,14 @@
cp -r public $out 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 { devShells.default = with pkgs; mkShell {
packages = [ optimize-images zola ]; packages = [ optimize-images zola ];
shellHook = linkFonts; shellHook = linkFonts;