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

Function populateDispatchWorkflowFiles

pkg/workflow/safe_outputs_dispatch.go:25–69  ·  view source on GitHub ↗

======================================== Safe Output Dispatch Workflow Handling ======================================== This file contains functions for managing dispatch-workflow safe output configurations: mapping workflow names to their file extensions so the runtime handler knows which file to

(data *WorkflowData, markdownPath string)

Source from the content-addressed store, hash-verified

23//
24// Priority order: .lock.yml > .yml > .md (same-batch compilation target)
25func populateDispatchWorkflowFiles(data *WorkflowData, markdownPath string) {
26 if data.SafeOutputs == nil || data.SafeOutputs.DispatchWorkflow == nil {
27 return
28 }
29
30 if len(data.SafeOutputs.DispatchWorkflow.Workflows) == 0 {
31 return
32 }
33
34 safeOutputsConfigLog.Printf("Populating workflow files for %d dispatch workflows", len(data.SafeOutputs.DispatchWorkflow.Workflows))
35
36 // Initialize WorkflowFiles map if not already initialized
37 if data.SafeOutputs.DispatchWorkflow.WorkflowFiles == nil {
38 data.SafeOutputs.DispatchWorkflow.WorkflowFiles = make(map[string]string)
39 }
40
41 for _, workflowName := range data.SafeOutputs.DispatchWorkflow.Workflows {
42 // Find the workflow file
43 fileResult, err := findWorkflowFile(workflowName, markdownPath)
44 if err != nil {
45 safeOutputsConfigLog.Printf("Warning: error finding workflow %s: %v", workflowName, err)
46 continue
47 }
48
49 // Determine which file to use - priority: .lock.yml > .yml > .md (batch target)
50 extension, found := resolveWorkflowExtension(fileResult)
51 if !found {
52 safeOutputsConfigLog.Printf("Warning: no workflow file found for %s (checked .lock.yml, .yml, .md)", workflowName)
53 continue
54 }
55
56 // Store the file extension for runtime use
57 data.SafeOutputs.DispatchWorkflow.WorkflowFiles[workflowName] = extension
58 safeOutputsConfigLog.Printf("Mapped workflow %s to extension %s", workflowName, extension)
59
60 // Check if the target workflow declares aw_context in its workflow_dispatch.inputs.
61 // We check the lock file first (compiled YAML), falling back to the markdown frontmatter.
62 if workflowHasAwContextInput(fileResult, workflowName) {
63 data.SafeOutputs.DispatchWorkflow.AwContextWorkflows = append(
64 data.SafeOutputs.DispatchWorkflow.AwContextWorkflows, workflowName,
65 )
66 safeOutputsConfigLog.Printf("Workflow %s declares aw_context input", workflowName)
67 }
68 }
69}
70
71// workflowHasAwContextInput reports whether the workflow identified by fileResult
72// has aw_context declared in its workflow_dispatch.inputs.

Calls 4

findWorkflowFileFunction · 0.85
resolveWorkflowExtensionFunction · 0.85
PrintfMethod · 0.45