Fix schedule not trigger bug because matching full ref name with short ref name (#28874)

Fix #28533

Caused by #28691

(cherry picked from commit 23efd9d278)
This commit is contained in:
Lunny Xiao 2024-01-22 10:13:24 +08:00 committed by Earl Warren
parent 3b3747ffe8
commit 3d19921dbe
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -173,15 +173,20 @@ func notify(ctx context.Context, input *notifyInput) error {
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
input.Event, input.Event,
input.Payload, input.Payload,
input.Event == webhook_module.HookEventPush && input.Ref == input.Repo.DefaultBranch, input.Event == webhook_module.HookEventPush && git.RefName(input.Ref).BranchName() == input.Repo.DefaultBranch,
) )
if err != nil { if err != nil {
return fmt.Errorf("DetectWorkflows: %w", err) return fmt.Errorf("DetectWorkflows: %w", err)
} }
if len(workflows) == 0 { log.Trace("repo %s with commit %s event %s find %d workflows and %d schedules",
log.Trace("repo %s with commit %s couldn't find workflows", input.Repo.RepoPath(), commit.ID) input.Repo.RepoPath(),
} else { commit.ID,
input.Event,
len(workflows),
len(schedules),
)
for _, wf := range workflows { for _, wf := range workflows {
if actionsConfig.IsWorkflowDisabled(wf.EntryName) { if actionsConfig.IsWorkflowDisabled(wf.EntryName) {
log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName)
@ -192,7 +197,6 @@ func notify(ctx context.Context, input *notifyInput) error {
detectedWorkflows = append(detectedWorkflows, wf) detectedWorkflows = append(detectedWorkflows, wf)
} }
} }
}
if input.PullRequest != nil { if input.PullRequest != nil {
// detect pull_request_target workflows // detect pull_request_target workflows