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