Skip to content

Commit 633996d

Browse files
GiteaBotlunny
andauthored
Fix schedule not trigger bug because matching full ref name with short ref name (#28874) (#28888)
Backport #28874 by @lunny Fix #28533 Caused by #28691 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 7f0ce2d commit 633996d

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

services/actions/notifier_helper.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,28 @@ func notify(ctx context.Context, input *notifyInput) error {
152152
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
153153
input.Event,
154154
input.Payload,
155-
input.Event == webhook_module.HookEventPush && input.Ref == input.Repo.DefaultBranch,
155+
input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch,
156156
)
157157
if err != nil {
158158
return fmt.Errorf("DetectWorkflows: %w", err)
159159
}
160160

161-
if len(workflows) == 0 {
162-
log.Trace("repo %s with commit %s couldn't find workflows", input.Repo.RepoPath(), commit.ID)
163-
} else {
164-
for _, wf := range workflows {
165-
if actionsConfig.IsWorkflowDisabled(wf.EntryName) {
166-
log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName)
167-
continue
168-
}
161+
log.Trace("repo %s with commit %s event %s find %d workflows and %d schedules",
162+
input.Repo.RepoPath(),
163+
commit.ID,
164+
input.Event,
165+
len(workflows),
166+
len(schedules),
167+
)
169168

170-
if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget {
171-
detectedWorkflows = append(detectedWorkflows, wf)
172-
}
169+
for _, wf := range workflows {
170+
if actionsConfig.IsWorkflowDisabled(wf.EntryName) {
171+
log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName)
172+
continue
173+
}
174+
175+
if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget {
176+
detectedWorkflows = append(detectedWorkflows, wf)
173177
}
174178
}
175179

0 commit comments

Comments
 (0)