73 lines
1.9 KiB
Nix
Raw Normal View History

2024-01-22 16:44:51 +03:00
{ config, pkgs, inputs, ... }:
2023-04-25 17:27:42 +03:00
let
blog-hook = pkgs.writeShellApplication {
name = "blog-hook";
runtimeInputs = with pkgs; [ git hugo openssh go ];
text = ''
git pull
hugo -d ../docroot
'';
};
in {
2024-01-22 16:44:51 +03:00
sops.secrets.webhook-blog.sopsFile = inputs.self.secretsDir + /home-hypervisor/webhooks.yaml;
sops.secrets.webhook-blog.owner = "webhook";
sops.secrets.webhook-blog.restartUnits = [ "webhook.service" ];
2023-04-25 17:27:42 +03:00
persist.state.directories = [ "/var/lib/webhook" ];
users.users.webhook = {
description = "Webhook daemon user";
isSystemUser = true;
group = "webhook";
createHome = true;
home = "/var/lib/webhook";
};
2024-02-08 23:21:10 +03:00
systemd.services.webhook.serviceConfig.EnvironmentFile = config.sops.secrets.webhook-blog.path;
2023-04-25 17:27:42 +03:00
services.webhook = {
enable = true;
2024-01-21 16:29:00 +03:00
port = 9510;
2023-04-25 17:27:42 +03:00
group = "webhook";
user = "webhook";
hooksTemplated = {
publish-ataraxiadev-blog = ''
{
"id": "ataraxiadev-blog",
"execute-command": "${blog-hook}/bin/blog-hook",
"command-working-directory": "/srv/http/ataraxiadev.com/gitrepo",
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hmac-sha256",
"secret": "{{ getenv "HOOK_BLOG_SECRET" | js }}",
"parameter":
{
"source": "header",
"name": "X-Gitea-Signature"
}
}
},
{
"match":
{
"type": "value",
"value": "refs/heads/master",
"parameter":
{
"source": "payload",
"name": "ref"
}
}
}
]
}
}
'';
};
};
}