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

Function addActionWorkflowWithTracking

pkg/cli/add_command.go:669–708  ·  view source on GitHub ↗

addActionWorkflowWithTracking installs a raw GitHub Actions YAML workflow file (.yml) directly to the target directory without any frontmatter processing or compilation.

(resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions, githubWorkflowsDir, workflowName string)

Source from the content-addressed store, hash-verified

667// addActionWorkflowWithTracking installs a raw GitHub Actions YAML workflow file (.yml)
668// directly to the target directory without any frontmatter processing or compilation.
669func addActionWorkflowWithTracking(resolved *ResolvedWorkflow, tracker *FileTracker, opts AddOptions, githubWorkflowsDir, workflowName string) error {
670 destFile := filepath.Join(githubWorkflowsDir, workflowName+".yml")
671
672 addLog.Printf("Adding action workflow: dest=%s, content_size=%d bytes", destFile, len(resolved.Content))
673
674 if opts.Verbose {
675 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Adding action workflow: "+destFile))
676 }
677
678 fileExists := false
679 if fileutil.FileExists(destFile) {
680 fileExists = true
681 if !opts.Force {
682 if opts.FromWildcard {
683 fmt.Fprintln(os.Stderr, console.FormatWarningMessage(fmt.Sprintf("Action workflow '%s' already exists. Skipping.", workflowName+".yml")))
684 return nil
685 }
686 return fmt.Errorf("action workflow '%s' already exists in %s. Use --force to overwrite", workflowName+".yml", githubWorkflowsDir)
687 }
688 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Overwriting existing file: "+destFile))
689 }
690
691 if tracker != nil {
692 if fileExists {
693 tracker.TrackModified(destFile)
694 } else {
695 tracker.TrackCreated(destFile)
696 }
697 }
698
699 if err := os.WriteFile(destFile, resolved.Content, constants.FilePermPublic); err != nil {
700 return fmt.Errorf("failed to write action workflow file '%s': %w", destFile, err)
701 }
702
703 if !opts.Quiet {
704 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Added action workflow: "+filepath.Base(destFile)))
705 }
706
707 return nil
708}
709
710// addSkillFileWithTracking installs a single skill file from a package to the agentic engine
711// skill directory. The file's path relative to the skill directory is preserved so that

Callers 1

addWorkflowWithTrackingFunction · 0.85

Calls 8

FormatInfoMessageFunction · 0.92
FileExistsFunction · 0.92
FormatWarningMessageFunction · 0.92
FormatSuccessMessageFunction · 0.92
TrackModifiedMethod · 0.80
TrackCreatedMethod · 0.65
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected