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)
This commit is contained in:
Zettat123 2024-02-28 23:35:04 +08:00 committed by Earl Warren
parent 6e89eff490
commit 2b23f4bdee
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 0579CB2928A78A00
2 changed files with 10 additions and 1 deletions

View file

@ -406,6 +406,9 @@ func matchPullRequestEvent(gitRepo *git.Repository, commit *git.Commit, prPayloa
// all acts conditions should be satisfied // all acts conditions should be satisfied
for cond, vals := range acts { for cond, vals := range acts {
switch cond { switch cond {
case "types":
// types have been checked
continue
case "branches": case "branches":
refName := git.RefName(prPayload.PullRequest.Base.Ref) refName := git.RefName(prPayload.PullRequest.Base.Ref)
patterns, err := workflowpattern.CompilePatterns(vals...) patterns, err := workflowpattern.CompilePatterns(vals...)

View file

@ -152,7 +152,13 @@ func (n *actionsNotifier) IssueChangeAssignee(ctx context.Context, doer *user_mo
} else { } else {
action = api.HookIssueAssigned 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 // IssueChangeMilestone notifies assignee to notifiers