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