| 173 | } |
| 174 | |
| 175 | func getWorkflowsByName(client *api.Client, repo ghrepo.Interface, name string, states []WorkflowState) ([]Workflow, error) { |
| 176 | workflows, err := GetWorkflows(client, repo, 0) |
| 177 | if err != nil { |
| 178 | return nil, fmt.Errorf("couldn't fetch workflows for %s: %w", ghrepo.FullName(repo), err) |
| 179 | } |
| 180 | |
| 181 | var filtered []Workflow |
| 182 | for _, workflow := range workflows { |
| 183 | if !strings.EqualFold(workflow.Name, name) { |
| 184 | continue |
| 185 | } |
| 186 | if slices.Contains(states, workflow.State) { |
| 187 | filtered = append(filtered, workflow) |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return filtered, nil |
| 192 | } |
| 193 | |
| 194 | func ResolveWorkflow(p iprompter, io *iostreams.IOStreams, client *api.Client, repo ghrepo.Interface, prompt bool, workflowSelector string, states []WorkflowState) (*Workflow, error) { |
| 195 | if prompt { |