@@ -335,44 +335,47 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
335
335
}
336
336
337
337
func matchPullRequestEvent (commit * git.Commit , prPayload * api.PullRequestPayload , evt * jobparser.Event ) bool {
338
- // with no special filter parameters
339
- if len (evt .Acts ()) == 0 {
338
+ acts := evt .Acts ()
339
+ activityTypeMatched := false
340
+ matchTimes := 0
341
+
342
+ if vals , ok := acts ["types" ]; ! ok {
340
343
// defaultly, only pull request `opened`, `reopened` and `synchronized` will trigger workflow
341
344
// See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
342
- return prPayload .Action == api .HookIssueSynchronized || prPayload .Action == api .HookIssueOpened || prPayload .Action == api .HookIssueReOpened
345
+ activityTypeMatched = prPayload .Action == api .HookIssueSynchronized || prPayload .Action == api .HookIssueOpened || prPayload .Action == api .HookIssueReOpened
346
+ } else {
347
+ // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
348
+ // Actions with the same name:
349
+ // opened, edited, closed, reopened, assigned, unassigned
350
+ // Actions need to be converted:
351
+ // synchronized -> synchronize
352
+ // label_updated -> labeled
353
+ // label_cleared -> unlabeled
354
+ // Unsupported activity types:
355
+ // converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed, auto_merge_enabled, auto_merge_disabled
356
+
357
+ action := prPayload .Action
358
+ switch action {
359
+ case api .HookIssueSynchronized :
360
+ action = "synchronize"
361
+ case api .HookIssueLabelUpdated :
362
+ action = "labeled"
363
+ case api .HookIssueLabelCleared :
364
+ action = "unlabeled"
365
+ }
366
+ log .Trace ("matching pull_request %s with %v" , action , vals )
367
+ for _ , val := range vals {
368
+ if glob .MustCompile (val , '/' ).Match (string (action )) {
369
+ activityTypeMatched = true
370
+ matchTimes ++
371
+ break
372
+ }
373
+ }
343
374
}
344
375
345
- matchTimes := 0
346
376
// all acts conditions should be satisfied
347
- for cond , vals := range evt . Acts () {
377
+ for cond , vals := range acts {
348
378
switch cond {
349
- case "types" :
350
- // See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
351
- // Actions with the same name:
352
- // opened, edited, closed, reopened, assigned, unassigned
353
- // Actions need to be converted:
354
- // synchronized -> synchronize
355
- // label_updated -> labeled
356
- // label_cleared -> unlabeled
357
- // Unsupported activity types:
358
- // converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed, auto_merge_enabled, auto_merge_disabled
359
-
360
- action := prPayload .Action
361
- switch action {
362
- case api .HookIssueSynchronized :
363
- action = "synchronize"
364
- case api .HookIssueLabelUpdated :
365
- action = "labeled"
366
- case api .HookIssueLabelCleared :
367
- action = "unlabeled"
368
- }
369
- log .Trace ("matching pull_request %s with %v" , action , vals )
370
- for _ , val := range vals {
371
- if glob .MustCompile (val , '/' ).Match (string (action )) {
372
- matchTimes ++
373
- break
374
- }
375
- }
376
379
case "branches" :
377
380
refName := git .RefName (prPayload .PullRequest .Base .Ref )
378
381
patterns , err := workflowpattern .CompilePatterns (vals ... )
@@ -421,7 +424,7 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
421
424
log .Warn ("pull request event unsupported condition %q" , cond )
422
425
}
423
426
}
424
- return matchTimes == len (evt .Acts ())
427
+ return activityTypeMatched && matchTimes == len (evt .Acts ())
425
428
}
426
429
427
430
func matchIssueCommentEvent (commit * git.Commit , issueCommentPayload * api.IssueCommentPayload , evt * jobparser.Event ) bool {
0 commit comments