Skip to content

Commit ffa3571

Browse files
committed
don't trigger event when pull request close
1 parent 6884d54 commit ffa3571

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

modules/actions/workflows.go

+29-10
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
103103
return false
104104
}
105105

106-
// with no special filter parameters
107-
if len(evt.Acts) == 0 {
108-
return true
109-
}
110-
111106
switch triggedEvent {
112107
case webhook_module.HookEventCreate,
113108
webhook_module.HookEventDelete,
@@ -126,6 +121,9 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
126121
webhook_module.HookEventRepository,
127122
webhook_module.HookEventRelease,
128123
webhook_module.HookEventPackage:
124+
if len(evt.Acts) != 0 {
125+
log.Warn("Ignore unsupported %s event arguments %q", triggedEvent, evt.Acts)
126+
}
129127
// no special filter parameters for these events, just return true if name matched
130128
return true
131129

@@ -142,12 +140,17 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
142140
return matchIssueCommentEvent(commit, payload.(*api.IssueCommentPayload), evt)
143141

144142
default:
145-
log.Warn("unsupported event %q", triggedEvent.Event())
143+
log.Warn("unsupported event %q", triggedEvent)
146144
return false
147145
}
148146
}
149147

150148
func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobparser.Event) bool {
149+
// with no special filter parameters
150+
if len(evt.Acts) == 0 {
151+
return true
152+
}
153+
151154
matchTimes := 0
152155
// all acts conditions should be satisfied
153156
for cond, vals := range evt.Acts {
@@ -180,13 +183,18 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
180183
}
181184
}
182185
default:
183-
log.Warn("unsupported condition %q", cond)
186+
log.Warn("push event unsupported condition %q", cond)
184187
}
185188
}
186189
return matchTimes == len(evt.Acts)
187190
}
188191

189192
func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *jobparser.Event) bool {
193+
// with no special filter parameters
194+
if len(evt.Acts) == 0 {
195+
return true
196+
}
197+
190198
matchTimes := 0
191199
// all acts conditions should be satisfied
192200
for cond, vals := range evt.Acts {
@@ -199,13 +207,19 @@ func matchIssuesEvent(commit *git.Commit, issuePayload *api.IssuePayload, evt *j
199207
}
200208
}
201209
default:
202-
log.Warn("unsupported condition %q", cond)
210+
log.Warn("issue event unsupported condition %q", cond)
203211
}
204212
}
205213
return matchTimes == len(evt.Acts)
206214
}
207215

208216
func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload, evt *jobparser.Event) bool {
217+
// with no special filter parameters
218+
if len(evt.Acts) == 0 {
219+
// defautly, only pull request opened and synchronized will not trigger workflow
220+
return prPayload.Action == api.HookIssueSynchronized || prPayload.Action == api.HookIssueOpened
221+
}
222+
209223
matchTimes := 0
210224
// all acts conditions should be satisfied
211225
for cond, vals := range evt.Acts {
@@ -250,13 +264,18 @@ func matchPullRequestEvent(commit *git.Commit, prPayload *api.PullRequestPayload
250264
}
251265
}
252266
default:
253-
log.Warn("unsupported condition %q", cond)
267+
log.Warn("pull request event unsupported condition %q", cond)
254268
}
255269
}
256270
return matchTimes == len(evt.Acts)
257271
}
258272

259273
func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCommentPayload, evt *jobparser.Event) bool {
274+
// with no special filter parameters
275+
if len(evt.Acts) == 0 {
276+
return true
277+
}
278+
260279
matchTimes := 0
261280
// all acts conditions should be satisfied
262281
for cond, vals := range evt.Acts {
@@ -269,7 +288,7 @@ func matchIssueCommentEvent(commit *git.Commit, issueCommentPayload *api.IssueCo
269288
}
270289
}
271290
default:
272-
log.Warn("unsupported condition %q", cond)
291+
log.Warn("issue comment unsupported condition %q", cond)
273292
}
274293
}
275294
return matchTimes == len(evt.Acts)

0 commit comments

Comments
 (0)