From 6b9657a3c7afbc9e7c025d9ad5b5b6dba1560506 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 4 Jun 2025 22:41:32 +0900 Subject: [PATCH 1/2] Fix: skip paths check for tag push in workflows --- modules/actions/workflows.go | 8 ++++++++ modules/actions/workflows_test.go | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go index a538b6e290bec..ca2162584fb7f 100644 --- a/modules/actions/workflows.go +++ b/modules/actions/workflows.go @@ -311,6 +311,10 @@ func matchPushEvent(commit *git.Commit, pushPayload *api.PushPayload, evt *jobpa matchTimes++ } case "paths": + if refName.IsTag() { + matchTimes++ + break + } filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before) if err != nil { 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 } } case "paths-ignore": + if refName.IsTag() { + matchTimes++ + break + } filesChanged, err := commit.GetFilesChangedSinceCommit(pushPayload.Before) if err != nil { log.Error("GetFilesChangedSinceCommit [commit_sha1: %s]: %v", commit.ID.String(), err) diff --git a/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index c8e1e553fe94b..aeb5f41c1d5d6 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -125,6 +125,25 @@ func TestDetectMatched(t *testing.T) { yamlOn: "on: schedule", expected: true, }, + { + desc: "push to tag matches workflow with paths condition (should skip paths check)", + triggedEvent: webhook_module.HookEventPush, + payload: &api.PushPayload{ + Ref: "refs/tags/v1.0.0", + Before: "0000000", + Commits: []*api.PayloadCommit{ + { + ID: "abcdef123456", + Added: []string{"src/main.go"}, + Message: "Release v1.0.0", + }, + }, + }, + commit: nil, + yamlOn: "on:\n push:\n paths:\n - src/**", + expected: true, + }, + } for _, tc := range testCases { From 4da4f9d7ade035228bb482c39e4bebfa44454407 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 4 Jun 2025 23:30:06 +0900 Subject: [PATCH 2/2] Fix: skip paths check for tag push in workflows --- modules/actions/workflows_test.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index aeb5f41c1d5d6..e23431651da3b 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -126,24 +126,23 @@ func TestDetectMatched(t *testing.T) { expected: true, }, { - desc: "push to tag matches workflow with paths condition (should skip paths check)", - triggedEvent: webhook_module.HookEventPush, - payload: &api.PushPayload{ + desc: "push to tag matches workflow with paths condition (should skip paths check)", + triggedEvent: webhook_module.HookEventPush, + payload: &api.PushPayload{ Ref: "refs/tags/v1.0.0", Before: "0000000", Commits: []*api.PayloadCommit{ { ID: "abcdef123456", - Added: []string{"src/main.go"}, - Message: "Release v1.0.0", - }, - }, - }, - commit: nil, - yamlOn: "on:\n push:\n paths:\n - src/**", - expected: true, - }, - + Added: []string{"src/main.go"}, + Message: "Release v1.0.0", + }, + }, + }, + commit: nil, + yamlOn: "on:\n push:\n paths:\n - src/**", + expected: true, + }, } for _, tc := range testCases {