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

Function resolveWorkflowTargetDir

pkg/cli/add_command.go:442–459  ·  view source on GitHub ↗
(opts AddOptions)

Source from the content-addressed store, hash-verified

440}
441
442func resolveWorkflowTargetDir(opts AddOptions) (gitRoot, githubWorkflowsDir string, err error) {
443 gitRoot, err = gitutil.FindGitRoot()
444 if err != nil {
445 return "", "", fmt.Errorf("add workflow requires being in a git repository: %w", err)
446 }
447 if opts.WorkflowDir != "" {
448 if filepath.IsAbs(opts.WorkflowDir) {
449 return "", "", fmt.Errorf("workflow directory must be a relative path, got: %s", opts.WorkflowDir)
450 }
451 githubWorkflowsDir = filepath.Join(gitRoot, filepath.Clean(opts.WorkflowDir))
452 } else {
453 githubWorkflowsDir = filepath.Join(gitRoot, constants.GetWorkflowDir())
454 }
455 if err := os.MkdirAll(githubWorkflowsDir, constants.DirPermPublic); err != nil {
456 return "", "", fmt.Errorf("failed to create workflow directory %s: %w", githubWorkflowsDir, err)
457 }
458 return gitRoot, githubWorkflowsDir, nil
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)

Callers 1

addWorkflowWithTrackingFunction · 0.85

Calls 3

FindGitRootFunction · 0.92
GetWorkflowDirFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected