Skip to content

Commit 1f5010b

Browse files
authored
Merge pull request #448 from muzimuzhi/merge_group-filters
`branchs` and `branches-ignore` filters are available for `merge_group` event
2 parents ea4d85d + b14cf83 commit 1f5010b

8 files changed

+45
-25
lines changed

docs/checks.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,14 +1276,14 @@ actionlint validates the Webhook configurations:
12761276
- Some filters are only available for specific events as explained in [the official document][specific-paths-doc]
12771277
(see the following table).
12781278

1279-
| Filter name | Events where the filter is available |
1280-
|-------------------|-----------------------------------------------|
1281-
| `paths` | `push`, `pull_request`, `pull_request_target` |
1282-
| `paths-ignore` | `push`, `pull_request`, `pull_request_target` |
1283-
| `branches` | `push`, `pull_request`, `pull_request_target` |
1284-
| `branches-ignore` | `push`, `pull_request`, `pull_request_target` |
1285-
| `tags` | `push` |
1286-
| `tags-ignore` | `push` |
1279+
| Filter name | Events where the filter is available |
1280+
|-------------------|------------------------------------------------------------------------------|
1281+
| `paths` | `push`, `pull_request`, `pull_request_target` |
1282+
| `paths-ignore` | `push`, `pull_request`, `pull_request_target` |
1283+
| `branches` | `merge_group`, `push`, `pull_request`, `pull_request_target`, `workflow_run` |
1284+
| `branches-ignore` | `merge_group`, `push`, `pull_request`, `pull_request_target`, `workflow_run` |
1285+
| `tags` | `push` |
1286+
| `tags-ignore` | `push` |
12871287

12881288
The table of available Webhooks and their types are defined in [`all_webhooks.go`](../all_webhooks.go). It is generated
12891289
by [a script][generate-webhook-events] and kept to the latest by CI workflow triggered weekly.

rule_events.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (rule *RuleEvents) checkWebhookEvent(event *WebhookEvent) {
132132
}
133133

134134
// Some filters are available with specific events and exclusive
135+
// - on.merge_group.<branches|branches-ignore>
135136
// - on.<push|pull_request|pull_request_target>.<paths|paths-ignore>
136137
// - on.push.<branches|tags|branches-ignore|tags-ignore>
137138
// - on.<pull_request|pull_request_target>.<branches|branches-ignore>
@@ -146,7 +147,7 @@ func (rule *RuleEvents) checkWebhookEvent(event *WebhookEvent) {
146147
event.Branches,
147148
event.BranchesIgnore,
148149
hook,
149-
[]string{"push", "pull_request", "pull_request_target", "workflow_run"},
150+
[]string{"merge_group", "push", "pull_request", "pull_request_target", "workflow_run"},
150151
)
151152
rule.checkExclusiveFilters(
152153
event.Tags,
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
test.yaml:4:5: both "paths" and "paths-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
2-
test.yaml:6:5: both "branches" and "branches-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
3-
test.yaml:8:5: both "tags" and "tags-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
4-
test.yaml:11:5: both "paths" and "paths-ignore" filters cannot be used for the same event "pull_request". note: use '!' to negate patterns [events]
5-
test.yaml:13:5: both "branches" and "branches-ignore" filters cannot be used for the same event "pull_request". note: use '!' to negate patterns [events]
6-
test.yaml:16:5: both "paths" and "paths-ignore" filters cannot be used for the same event "pull_request_target". note: use '!' to negate patterns [events]
7-
test.yaml:18:5: both "branches" and "branches-ignore" filters cannot be used for the same event "pull_request_target". note: use '!' to negate patterns [events]
8-
test.yaml:22:5: both "branches" and "branches-ignore" filters cannot be used for the same event "workflow_run". note: use '!' to negate patterns [events]
1+
test.yaml:4:5: both "branches" and "branches-ignore" filters cannot be used for the same event "merge_group". note: use '!' to negate patterns [events]
2+
test.yaml:7:5: both "paths" and "paths-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
3+
test.yaml:9:5: both "branches" and "branches-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
4+
test.yaml:11:5: both "tags" and "tags-ignore" filters cannot be used for the same event "push". note: use '!' to negate patterns [events]
5+
test.yaml:14:5: both "paths" and "paths-ignore" filters cannot be used for the same event "pull_request". note: use '!' to negate patterns [events]
6+
test.yaml:16:5: both "branches" and "branches-ignore" filters cannot be used for the same event "pull_request". note: use '!' to negate patterns [events]
7+
test.yaml:19:5: both "paths" and "paths-ignore" filters cannot be used for the same event "pull_request_target". note: use '!' to negate patterns [events]
8+
test.yaml:21:5: both "branches" and "branches-ignore" filters cannot be used for the same event "pull_request_target". note: use '!' to negate patterns [events]
9+
test.yaml:25:5: both "branches" and "branches-ignore" filters cannot be used for the same event "workflow_run". note: use '!' to negate patterns [events]

testdata/err/exclusive_webhook_filters.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
on:
2+
merge_group:
3+
branches-ignore: bar
4+
branches: foo
25
push:
36
paths: path/to/foo
47
paths-ignore: path/to/bar
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
test.yaml:4:5: "paths" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target events [events]
2-
test.yaml:5:5: "paths-ignore" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target events [events]
3-
test.yaml:6:5: "branches" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target, workflow_run events [events]
4-
test.yaml:7:5: "branches-ignore" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target, workflow_run events [events]
5-
test.yaml:8:5: "tags" filter is not available for pull_request_review event. it is only for push event [events]
6-
test.yaml:9:5: "tags-ignore" filter is not available for pull_request_review event. it is only for push event [events]
7-
test.yaml:11:5: "tags" filter is not available for pull_request event. it is only for push event [events]
8-
test.yaml:12:5: "tags-ignore" filter is not available for pull_request event. it is only for push event [events]
1+
test.yaml:3:12: invalid activity type "opened" for "merge_group" Webhook event. available types are "checks_requested" [events]
2+
test.yaml:4:5: "paths" filter is not available for merge_group event. it is only for push, pull_request, pull_request_target events [events]
3+
test.yaml:5:5: "paths-ignore" filter is not available for merge_group event. it is only for push, pull_request, pull_request_target events [events]
4+
test.yaml:6:5: "tags" filter is not available for merge_group event. it is only for push event [events]
5+
test.yaml:7:5: "tags-ignore" filter is not available for merge_group event. it is only for push event [events]
6+
test.yaml:10:5: "paths" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target events [events]
7+
test.yaml:11:5: "paths-ignore" filter is not available for pull_request_review event. it is only for push, pull_request, pull_request_target events [events]
8+
test.yaml:12:5: "branches" filter is not available for pull_request_review event. it is only for merge_group, push, pull_request, pull_request_target, workflow_run events [events]
9+
test.yaml:13:5: "branches-ignore" filter is not available for pull_request_review event. it is only for merge_group, push, pull_request, pull_request_target, workflow_run events [events]
10+
test.yaml:14:5: "tags" filter is not available for pull_request_review event. it is only for push event [events]
11+
test.yaml:15:5: "tags-ignore" filter is not available for pull_request_review event. it is only for push event [events]
12+
test.yaml:17:5: "tags" filter is not available for pull_request event. it is only for push event [events]
13+
test.yaml:18:5: "tags-ignore" filter is not available for pull_request event. it is only for push event [events]

testdata/err/invalid_event_filters.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
on:
2+
merge_group:
3+
types: opened
4+
paths: /path/to/foo.txt
5+
paths-ignore: /path/to/bar.txt
6+
tags: v*.*.*
7+
tags-ignore: deploy/*
28
pull_request_review:
39
types: submitted
410
paths: /path/to/foo.txt

testdata/ok/filters_for_specific_events.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
on:
2+
merge_group:
3+
branches: main
24
push:
35
branches: main
46
tags: v*.*.*

testdata/ok/filters_ignore_for_specific_events.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
on:
2+
merge_group:
3+
branches-ignore: bar
24
push:
35
branches-ignore: test
46
tags-ignore: deploy/*

0 commit comments

Comments
 (0)