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

Function fetchWorkflowDependencies

pkg/cli/add_command.go:461–485  ·  view source on GitHub ↗
(ctx context.Context, workflowSpec *WorkflowSpec, sourceInfo *FetchedWorkflow, sourceContent []byte, githubWorkflowsDir string, tracker *FileTracker, opts AddOptions)

Source from the content-addressed store, hash-verified

459}
460
461func fetchWorkflowDependencies(ctx context.Context, workflowSpec *WorkflowSpec, sourceInfo *FetchedWorkflow, sourceContent []byte, githubWorkflowsDir string, tracker *FileTracker, opts AddOptions) error {
462 // For remote workflows, fetch and save all dependencies (includes, imports, dispatch workflows, resources)
463 if workflowSpec.RawURL != "" {
464 // Generic URL imports carry no GitHub repo context; dependency fetching is skipped.
465 return nil
466 }
467 if !isLocalWorkflowPath(workflowSpec.WorkflowPath) {
468 return fetchAllRemoteDependencies(ctx, string(sourceContent), workflowSpec, githubWorkflowsDir, opts.Verbose, opts.Force, tracker)
469 }
470 if sourceInfo == nil || !sourceInfo.IsLocal {
471 return nil
472 }
473
474 // For local workflows, collect and copy include dependencies from local paths
475 // The source directory is derived from the workflow's path
476 sourceDir := filepath.Dir(workflowSpec.WorkflowPath)
477 includeDeps, err := collectLocalIncludeDependencies(string(sourceContent), sourceDir, opts.Verbose)
478 if err != nil {
479 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to collect include dependencies: %v", err)))
480 }
481 if err := copyIncludeDependenciesFromPackageWithForce(includeDeps, githubWorkflowsDir, opts.Verbose, opts.Force, tracker); err != nil {
482 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Failed to copy include dependencies: %v", err)))
483 }
484 return nil
485}
486
487// When the fetch used a fallback path (e.g. .github/workflows/my-workflow.md instead
488// of the short-form my-workflow.md), SourcePath holds the actual repo-root-relative

Callers 1

addWorkflowWithTrackingFunction · 0.85

Tested by

no test coverage detected