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

Function addWorkflowWithTracking

pkg/cli/add_command.go:320–377  ·  view source on GitHub ↗

addWorkflowWithTracking adds a workflow using pre-fetched content with file tracking

(ctx context.Context, resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions)

Source from the content-addressed store, hash-verified

318
319// addWorkflowWithTracking adds a workflow using pre-fetched content with file tracking
320func addWorkflowWithTracking(ctx context.Context, resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions) error {
321 workflowSpec := resolved.Spec
322 sourceContent := resolved.Content
323 sourceInfo := resolved.SourceInfo
324
325 reportAddWorkflowStart(workflowSpec, sourceContent, opts)
326 if err := validateWorkflowSecurity(resolved, opts); err != nil {
327 return err
328 }
329 gitRoot, githubWorkflowsDir, err := resolveWorkflowTargetDir(opts)
330 if err != nil {
331 return err
332 }
333
334 workflowName := workflowSpec.WorkflowName
335 if opts.Name != "" {
336 workflowName = opts.Name
337 }
338 // Action workflow files (.yml) are copied as-is to .github/workflows/ without any
339 // frontmatter processing, dependency fetching, or compilation.
340 if resolved.IsActionWorkflow {
341 return addActionWorkflowWithTracking(resolved, tracker, opts, githubWorkflowsDir, workflowName)
342 }
343 // Package skill files are copied as-is to the agentic engine skill directory.
344 if resolved.IsPackageSkillFile {
345 return addSkillFileWithTracking(resolved, tracker, opts, gitRoot)
346 }
347 // Package agent files are copied as-is to the agentic engine agents directory.
348 if resolved.IsPackageAgentFile {
349 return addAgentFileWithTracking(resolved, tracker, opts, gitRoot)
350 }
351 skip, err := validateWorkflowDestination(githubWorkflowsDir, workflowName, opts)
352 if err != nil {
353 return err
354 }
355 if skip {
356 return nil
357 }
358 if err := fetchWorkflowDependencies(ctx, workflowSpec, sourceInfo, sourceContent, githubWorkflowsDir, tracker, opts); err != nil {
359 return err
360 }
361
362 destFile := filepath.Join(githubWorkflowsDir, workflowName+".md")
363 fileExists := fileutil.FileExists(destFile)
364 if fileExists {
365 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Overwriting existing file: "+destFile))
366 }
367 workflowSpec = resolvedWorkflowSpec(workflowSpec, sourceInfo)
368 content, err := processWorkflowContentModifications(string(sourceContent), workflowSpec, sourceInfo, githubWorkflowsDir, opts)
369 if err != nil {
370 return err
371 }
372 if err := trackAndWriteWorkflowFile(destFile, content, fileExists, opts, tracker); err != nil {
373 return err
374 }
375 compileAddedWorkflow(ctx, destFile, workflowSpec, githubWorkflowsDir, tracker, opts)
376 return nil
377}

Calls 14

FileExistsFunction · 0.92
FormatInfoMessageFunction · 0.92
reportAddWorkflowStartFunction · 0.85
validateWorkflowSecurityFunction · 0.85
resolveWorkflowTargetDirFunction · 0.85
addSkillFileWithTrackingFunction · 0.85
addAgentFileWithTrackingFunction · 0.85
resolvedWorkflowSpecFunction · 0.85