summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-02-02 20:40:08 +0800
committerGitHub <noreply@github.com>2023-02-02 20:40:08 +0800
commit368d43643f8f8ed1bfb1462d5cae586c90e93383 (patch)
tree6791430f82ddf5cad2a4e17dd03c762091ae2921
parent98770d3db8198714789c3182c14950d365ae4fb1 (diff)
downloadgitea-368d43643f8f8ed1bfb1462d5cae586c90e93383.tar.gz
gitea-368d43643f8f8ed1bfb1462d5cae586c90e93383.zip
Fix actions workflow branches match bug (#22724)
caused by #22680 `pushPayload.Ref` and `prPayload.PullRequest.Base.Ref` have the format like `refs/heads/<branch_name>`, so we need to trim the prefix before comparing.
-rw-r--r--modules/actions/workflows.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go
index c1c8e71f53..7f0e6e4564 100644
--- a/modules/actions/workflows.go
+++ b/modules/actions/workflows.go
@@ -75,7 +75,6 @@ func DetectWorkflows(commit *git.Commit, triggedEvent webhook_module.HookEventTy
if evt.Name != triggedEvent.Event() {
continue
}
-
if detectMatched(commit, triggedEvent, payload, evt) {
workflows[entry.Name()] = content
}
@@ -105,8 +104,9 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
for cond, vals := range evt.Acts {
switch cond {
case "branches", "tags":
+ refShortName := git.RefName(pushPayload.Ref).ShortName()
for _, val := range vals {
- if glob.MustCompile(val, '/').Match(pushPayload.Ref) {
+ if glob.MustCompile(val, '/').Match(refShortName) {
matchTimes++
break
}
@@ -160,8 +160,9 @@ func detectMatched(commit *git.Commit, triggedEvent webhook_module.HookEventType
}
}
case "branches":
+ refShortName := git.RefName(prPayload.PullRequest.Base.Ref).ShortName()
for _, val := range vals {
- if glob.MustCompile(val, '/').Match(prPayload.PullRequest.Base.Ref) {
+ if glob.MustCompile(val, '/').Match(refShortName) {
matchTimes++
break
}