Skip to content

Commit

Permalink
Fix schedule not trigger bug because matching full ref name with shor…
Browse files Browse the repository at this point in the history
…t ref name (go-gitea#28874)

Fix go-gitea#28533

Caused by go-gitea#28691
  • Loading branch information
lunny authored and GiteaBot committed Jan 22, 2024
1 parent 7f0ce2d commit 6e1b92a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions services/actions/notifier_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,24 +152,28 @@ func notify(ctx context.Context, input *notifyInput) error {
workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit,
input.Event,
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 {
return fmt.Errorf("DetectWorkflows: %w", err)
}

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

if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget {
detectedWorkflows = append(detectedWorkflows, wf)
}
for _, wf := range workflows {
if actionsConfig.IsWorkflowDisabled(wf.EntryName) {
log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName)
continue
}

if wf.TriggerEvent.Name != actions_module.GithubEventPullRequestTarget {
detectedWorkflows = append(detectedWorkflows, wf)
}
}

Expand Down

0 comments on commit 6e1b92a

Please sign in to comment.