RunSpecificWorkflowInteractively runs a specific workflow in interactive mode This is similar to RunWorkflowInteractively but skips the workflow selection step since the workflow name is already known. It will still collect inputs if the workflow has them.
(ctx context.Context, opts RunWorkflowOptions)
| 378 | // This is similar to RunWorkflowInteractively but skips the workflow selection step |
| 379 | // since the workflow name is already known. It will still collect inputs if the workflow has them. |
| 380 | func RunSpecificWorkflowInteractively(ctx context.Context, opts RunWorkflowOptions) error { |
| 381 | runInteractiveLog.Printf("Running specific workflow interactively: %s", opts.WorkflowName) |
| 382 | |
| 383 | // Find the workflow file |
| 384 | workflowsDir := constants.GetWorkflowDir() |
| 385 | mdFile := filepath.Join(workflowsDir, opts.WorkflowName+".md") |
| 386 | |
| 387 | // Check if file exists |
| 388 | if _, err := os.Stat(mdFile); os.IsNotExist(err) { |
| 389 | return fmt.Errorf("workflow file not found: %s", mdFile) |
| 390 | } |
| 391 | |
| 392 | // Get workflow inputs |
| 393 | inputs, err := getWorkflowInputs(mdFile) |
| 394 | if err != nil { |
| 395 | runInteractiveLog.Printf("Failed to get inputs for workflow %s: %v", opts.WorkflowName, err) |
| 396 | // Continue without inputs - they might not be required |
| 397 | inputs = nil |
| 398 | } |
| 399 | |
| 400 | // Create workflow option for display |
| 401 | wf := &WorkflowOption{ |
| 402 | Name: opts.WorkflowName, |
| 403 | Description: buildWorkflowDescription(inputs), |
| 404 | FilePath: mdFile, |
| 405 | Inputs: inputs, |
| 406 | } |
| 407 | |
| 408 | // Show workflow info if there are inputs |
| 409 | if len(inputs) > 0 { |
| 410 | showWorkflowInfo(wf) |
| 411 | } |
| 412 | |
| 413 | // Collect workflow inputs if needed |
| 414 | inputValues, err := collectWorkflowInputs(ctx, wf) |
| 415 | if err != nil { |
| 416 | return fmt.Errorf("failed to collect workflow inputs: %w", err) |
| 417 | } |
| 418 | |
| 419 | // Confirm execution (skip if no inputs were collected - user already confirmed they want to run) |
| 420 | if len(inputValues) > 0 && !confirmExecution(ctx, wf, inputValues) { |
| 421 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Workflow execution cancelled")) |
| 422 | return nil |
| 423 | } |
| 424 | |
| 425 | // Build command string for display |
| 426 | cmdStr := buildCommandString(opts.WorkflowName, inputValues, opts.RepoOverride, opts.RefOverride, opts.AutoMergePRs, opts.Push, opts.EngineOverride) |
| 427 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("\nRunning workflow...")) |
| 428 | fmt.Fprintln(os.Stderr, console.FormatCommandMessage("Equivalent command: "+cmdStr)) |
| 429 | fmt.Fprintln(os.Stderr, "") |
| 430 | |
| 431 | // Execute the workflow |
| 432 | err = RunWorkflowOnGitHub(ctx, opts.WorkflowName, RunOptions{ |
| 433 | Enable: false, |
| 434 | EngineOverride: opts.EngineOverride, |
| 435 | RepoOverride: opts.RepoOverride, |
| 436 | RefOverride: opts.RefOverride, |
| 437 | AutoMergePRs: opts.AutoMergePRs, |
no test coverage detected