From 2b23f4bdee553d718c5397d9b7e3dae0a5a41dd2 Mon Sep 17 00:00:00 2001
From: Zettat123 <zettat123@gmail.com>
Date: Wed, 28 Feb 2024 23:35:04 +0800
Subject: [PATCH] Fix workflow trigger event bugs (#29467)

1. Fix incorrect `HookEventType` for issue-related events in
`IssueChangeAssignee`
2. Add `case "types"` in the `switch` block in `matchPullRequestEvent`
to avoid warning logs

(cherry picked from commit 1ad4bb9eb7641a552c5b88a43eb91d59ec5c0edf)
---
 modules/actions/workflows.go | 3 +++
 services/actions/notifier.go | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go
index 81ab26bc2..8317f16db 100644
--- a/modules/actions/workflows.go
+++ b/modules/actions/workflows.go
@@ -406,6 +406,9 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
 	// all acts conditions should be satisfied
 	for cond, vals := range acts {
 		switch cond {
+		case "types":
+			// types have been checked
+			continue
 		case "branches":
 			refName := git.RefName(prPayload.PullRequest.Base.Ref)
 			patterns, err := workflowpattern.CompilePatterns(vals...)
diff --git a/services/actions/notifier.go b/services/actions/notifier.go
index e144484da..1e99c51a8 100644
--- a/services/actions/notifier.go
+++ b/services/actions/notifier.go
@@ -152,7 +152,13 @@ func (n *actionsNotifier) IssueChangeAssignee(ctx context.Context, doer *user_mo
 	} else {
 		action = api.HookIssueAssigned
 	}
-	notifyIssueChange(ctx, doer, issue, webhook_module.HookEventPullRequestAssign, action)
+
+	hookEvent := webhook_module.HookEventIssueAssign
+	if issue.IsPull {
+		hookEvent = webhook_module.HookEventPullRequestAssign
+	}
+
+	notifyIssueChange(ctx, doer, issue, hookEvent, action)
 }
 
 // IssueChangeMilestone notifies assignee to notifiers