relay: defer event policy to Hermes
This commit is contained in:
+36
-3
@@ -20,6 +20,37 @@ let
|
||||
# but explicitly walled off `master`'s push/merge/approve whitelists so
|
||||
# nothing she does lands without darman clicking merge.
|
||||
lunaRepos = [ "darman/homelab" ];
|
||||
|
||||
# Forward every Gitea event to the generic Mars relay. Hermes owns the
|
||||
# decision about which events matter and what to do with them.
|
||||
giteaWebhookEvents = [
|
||||
"create"
|
||||
"delete"
|
||||
"fork"
|
||||
"push"
|
||||
"issues"
|
||||
"issue_assign"
|
||||
"issue_label"
|
||||
"issue_milestone"
|
||||
"issue_comment"
|
||||
"pull_request"
|
||||
"pull_request_assign"
|
||||
"pull_request_label"
|
||||
"pull_request_milestone"
|
||||
"pull_request_comment"
|
||||
"pull_request_review_approved"
|
||||
"pull_request_review_rejected"
|
||||
"pull_request_review_comment"
|
||||
"pull_request_sync"
|
||||
"pull_request_review_request"
|
||||
"wiki"
|
||||
"repository"
|
||||
"release"
|
||||
"package"
|
||||
"status"
|
||||
"workflow_run"
|
||||
"workflow_job"
|
||||
];
|
||||
in
|
||||
{
|
||||
services.gitea = {
|
||||
@@ -265,8 +296,9 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
# Register the HomeLab PR-comment webhook on Gitea. This is idempotent: it
|
||||
# updates the existing hook for the relay target or creates it when absent.
|
||||
# Register the generic Gitea webhook. This is idempotent: it updates the
|
||||
# existing hook for the relay target or creates it when absent. Event policy
|
||||
# belongs to Hermes, so the source sends the complete Gitea event set.
|
||||
systemd.services.gitea-hermes-webhook-provision = {
|
||||
description = "Provision Gitea webhook for Hermes PR comments";
|
||||
after = [ "gitea.service" ];
|
||||
@@ -290,7 +322,8 @@ in
|
||||
auth=(-H "Authorization: token $admin_token")
|
||||
target="http://mars.orbit.sol:8645/gitea"
|
||||
body="$(jq -n --arg url "$target" --arg secret "$secret" \
|
||||
'{type: "gitea", config: {content_type: "json", url: $url, secret: $secret}, events: ["pull_request_comment", "pull_request_review_comment"], active: true}')"
|
||||
--argjson events '${builtins.toJSON giteaWebhookEvents}' \
|
||||
'{type: "gitea", config: {content_type: "json", url: $url, secret: $secret}, events: $events, active: true}')"
|
||||
|
||||
hook_id="$(curl -fsS "''${auth[@]}" "$api/repos/darman/homelab/hooks" \
|
||||
| jq -r --arg url "$target" 'first(.[] | select(.type == "gitea" and .config.url == $url)) | .id // empty')"
|
||||
|
||||
Reference in New Issue
Block a user