Skip to content

Commit f10e909

Browse files
authored
Fix: skip paths check on tag push events in workflows (#34602) (#34670)
1 parent a3b2543 commit f10e909

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

modules/actions/workflows.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
311311
matchTimes++
312312
}
313313
case "paths":
314+
if refName.IsTag() {
315+
matchTimes++
316+
break
317+
}
314318
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
315319
if err != nil {
316320
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
@@ -324,6 +328,10 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
324328
}
325329
}
326330
case "paths-ignore":
331+
if refName.IsTag() {
332+
matchTimes++
333+
break
334+
}
327335
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
328336
if err != nil {
329337
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)

modules/actions/workflows_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ func TestDetectMatched(t *testing.T) {
125125
yamlOn: "on: schedule",
126126
expected: true,
127127
},
128+
{
129+
desc: "push to tag matches workflow with paths condition (should skip paths check)",
130+
triggedEvent: webhook_module.HookEventPush,
131+
payload: &api.PushPayload{
132+
Ref: "refs/tags/v1.0.0",
133+
Before: "0000000",
134+
Commits: []*api.PayloadCommit{
135+
{
136+
ID: "abcdef123456",
137+
Added: []string{"src/main.go"},
138+
Message: "Release v1.0.0",
139+
},
140+
},
141+
},
142+
commit: nil,
143+
yamlOn: "on:\n push:\n paths:\n - src/**",
144+
expected: true,
145+
},
128146
}
129147

130148
for _, tc := range testCases {

0 commit comments

Comments
 (0)