MCPcopy Create free account
hub / github.com/github/gh-aw / findRunnableWorkflows

Function findRunnableWorkflows

pkg/cli/run_interactive.go:110–162  ·  view source on GitHub ↗

findRunnableWorkflows finds all workflows that support workflow_dispatch

(verbose bool)

Source from the content-addressed store, hash-verified

108
109// findRunnableWorkflows finds all workflows that support workflow_dispatch
110func 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
165func buildWorkflowDescription(inputs map[string]*workflow.InputDefinition) string {

Calls 9

GetWorkflowDirFunction · 0.92
getMarkdownWorkflowFilesFunction · 0.85
IsRunnableFunction · 0.85
normalizeWorkflowIDFunction · 0.85
getWorkflowInputsFunction · 0.85
buildWorkflowDescriptionFunction · 0.85
PrintMethod · 0.80
ErrorfMethod · 0.45
PrintfMethod · 0.45