From ca6bbc6c6d6f77e423135221c2bf79713c4eb14a Mon Sep 17 00:00:00 2001 From: Christopher Homberger Date: Mon, 17 Mar 2025 22:43:23 +0100 Subject: [PATCH] wip --- models/webhook/webhook_test.go | 2 +- modules/webhook/type.go | 1 + routers/api/v1/utils/hook.go | 1 + routers/web/repo/setting/webhook.go | 1 + services/forms/repo_form.go | 1 + services/webhook/payloader.go | 2 ++ 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/models/webhook/webhook_test.go b/models/webhook/webhook_test.go index 6ff77a380d..d1fe722dd0 100644 --- a/models/webhook/webhook_test.go +++ b/models/webhook/webhook_test.go @@ -73,7 +73,7 @@ func TestWebhook_EventsArray(t *testing.T) { "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_job", + "package", "status", "workflow_run", "workflow_job", }, (&Webhook{ HookEvent: &webhook_module.HookEvent{SendEverything: true}, diff --git a/modules/webhook/type.go b/modules/webhook/type.go index bcf8903b2b..89c6a4bfe5 100644 --- a/modules/webhook/type.go +++ b/modules/webhook/type.go @@ -68,6 +68,7 @@ func AllEvents() []HookEventType { HookEventRelease, HookEventPackage, HookEventStatus, + HookEventWorkflowRun, HookEventWorkflowJob, } } diff --git a/routers/api/v1/utils/hook.go b/routers/api/v1/utils/hook.go index ce0c1b5097..3b87a8f257 100644 --- a/routers/api/v1/utils/hook.go +++ b/routers/api/v1/utils/hook.go @@ -207,6 +207,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI webhook_module.HookEventRelease: util.SliceContainsString(form.Events, string(webhook_module.HookEventRelease), true), webhook_module.HookEventPackage: util.SliceContainsString(form.Events, string(webhook_module.HookEventPackage), true), webhook_module.HookEventStatus: util.SliceContainsString(form.Events, string(webhook_module.HookEventStatus), true), + webhook_module.HookEventWorkflowRun: util.SliceContainsString(form.Events, string(webhook_module.HookEventWorkflowRun), true), webhook_module.HookEventWorkflowJob: util.SliceContainsString(form.Events, string(webhook_module.HookEventWorkflowJob), true), }, BranchFilter: form.BranchFilter, diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index d3151a86a2..006abafe57 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -185,6 +185,7 @@ func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent { webhook_module.HookEventRepository: form.Repository, webhook_module.HookEventPackage: form.Package, webhook_module.HookEventStatus: form.Status, + webhook_module.HookEventWorkflowRun: form.WorkflowRun, webhook_module.HookEventWorkflowJob: form.WorkflowJob, }, BranchFilter: form.BranchFilter, diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 1366d30b1f..bf7554971d 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -237,6 +237,7 @@ type WebhookForm struct { Release bool Package bool Status bool + WorkflowRun bool WorkflowJob bool Active bool BranchFilter string `binding:"GlobPattern"` diff --git a/services/webhook/payloader.go b/services/webhook/payloader.go index adb7243fb1..058dd08589 100644 --- a/services/webhook/payloader.go +++ b/services/webhook/payloader.go @@ -81,6 +81,8 @@ func newPayload[T any](rc payloadConvertor[T], data []byte, event webhook_module return convertUnmarshalledJSON(rc.Package, data) case webhook_module.HookEventStatus: return convertUnmarshalledJSON(rc.Status, data) + // case webhook_module.HookEventWorkflowRun: + // return convertUnmarshalledJSON(rc.WorkflowRun, data) case webhook_module.HookEventWorkflowJob: return convertUnmarshalledJSON(rc.WorkflowJob, data) }