findRunnableWorkflows finds all workflows that support workflow_dispatch
(verbose bool)
| 108 | |
| 109 | // findRunnableWorkflows finds all workflows that support workflow_dispatch |
| 110 | func findRunnableWorkflows(verbose bool) ([]WorkflowOption, error) { |
| 111 | runInteractiveLog.Print("Finding runnable workflows") |
| 112 | |
| 113 | // Get all markdown workflow files |
| 114 | workflowsDir := constants.GetWorkflowDir() |
| 115 | mdFiles, err := getMarkdownWorkflowFiles(workflowsDir) |
| 116 | if err != nil { |
| 117 | return nil, fmt.Errorf("failed to get workflow files: %w", err) |
| 118 | } |
| 119 | |
| 120 | if verbose { |
| 121 | fmt.Fprintf(os.Stderr, "Found %d workflow files, checking for workflow_dispatch trigger...\n", len(mdFiles)) |
| 122 | } |
| 123 | |
| 124 | var runnableWorkflows []WorkflowOption |
| 125 | |
| 126 | for _, mdFile := range mdFiles { |
| 127 | // Check if workflow is runnable |
| 128 | runnable, err := IsRunnable(mdFile) |
| 129 | if err != nil { |
| 130 | runInteractiveLog.Printf("Failed to check if workflow %s is runnable: %v", mdFile, err) |
| 131 | continue |
| 132 | } |
| 133 | |
| 134 | if !runnable { |
| 135 | continue |
| 136 | } |
| 137 | |
| 138 | // Extract workflow name |
| 139 | name := normalizeWorkflowID(mdFile) |
| 140 | |
| 141 | // Get workflow inputs |
| 142 | inputs, err := getWorkflowInputs(mdFile) |
| 143 | if err != nil { |
| 144 | runInteractiveLog.Printf("Failed to get inputs for workflow %s: %v", mdFile, err) |
| 145 | // Continue without inputs |
| 146 | inputs = nil |
| 147 | } |
| 148 | |
| 149 | // Build description |
| 150 | description := buildWorkflowDescription(inputs) |
| 151 | |
| 152 | runnableWorkflows = append(runnableWorkflows, WorkflowOption{ |
| 153 | Name: name, |
| 154 | Description: description, |
| 155 | FilePath: mdFile, |
| 156 | Inputs: inputs, |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | runInteractiveLog.Printf("Found %d runnable workflows", len(runnableWorkflows)) |
| 161 | return runnableWorkflows, nil |
| 162 | } |
| 163 | |
| 164 | // buildWorkflowDescription creates a description string for a workflow |
| 165 | func buildWorkflowDescription(inputs map[string]*workflow.InputDefinition) string { |