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