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.
This commit is contained in:
Earl Warren 2025-11-06 06:59:57 +01:00
parent e6522c1ecc
commit 6a99709a1c
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -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
}