@@ -299,44 +299,47 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
299299}
300300
301301func matchPullRequestEvent (commit * git.Commit , prPayload * api.PullRequestPayload , evt * jobparser.Event ) bool {
302- // with no special filter parameters
303- if len (evt .Acts ()) == 0 {
302+ acts := evt .Acts ()
303+ activityTypeMatched := false
304+ matchTimes := 0
305+
306+ if vals , ok := acts ["types" ]; ! ok {
304307 // defaultly, only pull request `opened`, `reopened` and `synchronized` will trigger workflow
305308 // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
306- return prPayload .Action == api .HookIssueSynchronized || prPayload .Action == api .HookIssueOpened || prPayload .Action == api .HookIssueReOpened
309+ activityTypeMatched = prPayload .Action == api .HookIssueSynchronized || prPayload .Action == api .HookIssueOpened || prPayload .Action == api .HookIssueReOpened
310+ } else {
311+ // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
312+ // Actions with the same name:
313+ // opened, edited, closed, reopened, assigned, unassigned
314+ // Actions need to be converted:
315+ // synchronized -> synchronize
316+ // label_updated -> labeled
317+ // label_cleared -> unlabeled
318+ // Unsupported activity types:
319+ // converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed, auto_merge_enabled, auto_merge_disabled
320+
321+ action := prPayload .Action
322+ switch action {
323+ case api .HookIssueSynchronized :
324+ action = "synchronize"
325+ case api .HookIssueLabelUpdated :
326+ action = "labeled"
327+ case api .HookIssueLabelCleared :
328+ action = "unlabeled"
329+ }
330+ log .Trace ("matching pull_request %s with %v" , action , vals )
331+ for _ , val := range vals {
332+ if glob .MustCompile (val , '/' ).Match (string (action )) {
333+ activityTypeMatched = true
334+ matchTimes ++
335+ break
336+ }
337+ }
307338 }
308339
309- matchTimes := 0
310340 // all acts conditions should be satisfied
311- for cond , vals := range evt . Acts () {
341+ for cond , vals := range acts {
312342 switch cond {
313- case "types" :
314- // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
315- // Actions with the same name:
316- // opened, edited, closed, reopened, assigned, unassigned
317- // Actions need to be converted:
318- // synchronized -> synchronize
319- // label_updated -> labeled
320- // label_cleared -> unlabeled
321- // Unsupported activity types:
322- // converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed, auto_merge_enabled, auto_merge_disabled
323-
324- action := prPayload .Action
325- switch action {
326- case api .HookIssueSynchronized :
327- action = "synchronize"
328- case api .HookIssueLabelUpdated :
329- action = "labeled"
330- case api .HookIssueLabelCleared :
331- action = "unlabeled"
332- }
333- log .Trace ("matching pull_request %s with %v" , action , vals )
334- for _ , val := range vals {
335- if glob .MustCompile (val , '/' ).Match (string (action )) {
336- matchTimes ++
337- break
338- }
339- }
340343 case "branches" :
341344 refName := git .RefName (prPayload .PullRequest .Base .Ref )
342345 patterns , err := workflowpattern .CompilePatterns (vals ... )
@@ -385,7 +388,7 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
385388 log .Warn ("pull request event unsupported condition %q" , cond )
386389 }
387390 }
388- return matchTimes == len (evt .Acts ())
391+ return activityTypeMatched && matchTimes == len (evt .Acts ())
389392}
390393
391394func matchIssueCommentEvent (commit * git.Commit , issueCommentPayload * api.IssueCommentPayload , evt * jobparser.Event ) bool {
0 commit comments