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

Function RunWorkflowInteractively

pkg/cli/run_interactive.go:32–107  ·  view source on GitHub ↗

RunWorkflowInteractively runs a workflow in interactive mode

(ctx context.Context, verbose bool, repoOverride string, refOverride string, autoMergePRs bool, push bool, engineOverride string, dryRun bool)

Source from the content-addressed store, hash-verified

30
31// RunWorkflowInteractively runs a workflow in interactive mode
32func RunWorkflowInteractively(ctx context.Context, verbose bool, repoOverride string, refOverride string, autoMergePRs bool, push bool, engineOverride string, dryRun bool) error {
33 runInteractiveLog.Print("Starting interactive workflow run")
34
35 // Check if running in CI environment
36 if IsRunningInCI() {
37 return errors.New("interactive mode cannot be used in CI environments")
38 }
39
40 if verbose {
41 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Starting interactive workflow run..."))
42 }
43
44 // Step 1: Find workflows with workflow_dispatch trigger
45 workflows, err := findRunnableWorkflows(verbose)
46 if err != nil {
47 return fmt.Errorf("failed to find runnable workflows: %w", err)
48 }
49
50 if len(workflows) == 0 {
51 return errors.New("no runnable workflows found. Workflows must have 'workflow_dispatch' trigger")
52 }
53
54 // Step 2: Let user select a workflow
55 selectedWorkflow, err := selectWorkflow(ctx, workflows)
56 if err != nil {
57 return fmt.Errorf("workflow selection cancelled or failed: %w", err)
58 }
59
60 runInteractiveLog.Printf("Selected workflow: %s", selectedWorkflow.Name)
61
62 // Step 3: Show workflow information
63 showWorkflowInfo(selectedWorkflow)
64
65 // Step 4: Collect workflow inputs if needed
66 inputValues, err := collectWorkflowInputs(ctx, selectedWorkflow)
67 if err != nil {
68 return fmt.Errorf("failed to collect workflow inputs: %w", err)
69 }
70
71 // Step 5: Confirm execution
72 if !confirmExecution(ctx, selectedWorkflow, inputValues) {
73 fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Workflow execution cancelled"))
74 return nil
75 }
76
77 // Step 6: Build command string for display
78 cmdStr := buildCommandString(selectedWorkflow.Name, inputValues, repoOverride, refOverride, autoMergePRs, push, engineOverride)
79 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("\nRunning workflow..."))
80 fmt.Fprintln(os.Stderr, console.FormatCommandMessage("Equivalent command: "+cmdStr))
81 fmt.Fprintln(os.Stderr, "")
82
83 // Step 7: Execute the workflow
84 err = RunWorkflowOnGitHub(ctx, selectedWorkflow.Name, RunOptions{
85 Enable: false,
86 EngineOverride: engineOverride,
87 RepoOverride: repoOverride,
88 RefOverride: refOverride,
89 AutoMergePRs: autoMergePRs,

Callers 1

main.goFile · 0.92

Calls 15

FormatInfoMessageFunction · 0.92
FormatWarningMessageFunction · 0.92
FormatCommandMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
IsRunningInCIFunction · 0.85
findRunnableWorkflowsFunction · 0.85
selectWorkflowFunction · 0.85
showWorkflowInfoFunction · 0.85
collectWorkflowInputsFunction · 0.85
confirmExecutionFunction · 0.85
buildCommandStringFunction · 0.85
RunWorkflowOnGitHubFunction · 0.85

Tested by

no test coverage detected