Skip to content

Commit b408bf2

Browse files
Fix: skip paths check on tag push events in workflows (#34602)
## Summary Fix skipping of `paths` condition in workflows triggered by tag push events. ## Details - Ensure workflows triggered by tag pushes bypass the `paths` filter check. - Prevent incorrect skipping of workflows due to `paths` conditions on tag pushes. - Added and updated unit tests to verify correct behavior.
1 parent c6b2cbd commit b408bf2

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
@@ -313,6 +313,10 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
313313
matchTimes++
314314
}
315315
case "paths":
316+
if refName.IsTag() {
317+
matchTimes++
318+
break
319+
}
316320
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
317321
if err != nil {
318322
log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err)
@@ -326,6 +330,10 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa
326330
}
327331
}
328332
case "paths-ignore":
333+
if refName.IsTag() {
334+
matchTimes++
335+
break
336+
}
329337
filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before)
330338
if err != nil {
331339
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)