From 6a99709a1cf1aff48daab2ba15cb478ca4e881f1 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 6 Nov 2025 06:59:57 +0100 Subject: [PATCH] chore(refactor): detectWorkflow process pull_request_target first Collecting pull_request_target workflows before the others changes nothing. They will be first in the list but there is no guarantee or need for ordering. This is in preparation of a future commit that needs to know the base commit before detecting workflows that are not pull_request_target. --- services/actions/notifier_helper.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 6a9f7534b8..ed6139e8cb 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -242,17 +242,6 @@ func detectWorkflows(ctx context.Context, input *notifyInput, gitRepo *git.Repos len(schedules), ) - 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) - } - } - if input.PullRequest != nil && !actions_module.IsDefaultBranchWorkflow(input.Event) { // detect pull_request_target workflows baseRef := git.BranchPrefix + input.PullRequest.BaseBranch @@ -280,6 +269,18 @@ func detectWorkflows(ctx context.Context, input *notifyInput, gitRepo *git.Repos } } } + + 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) + } + } + return detectedWorkflows, schedules, nil }