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

Function trackAndWriteWorkflowFile

pkg/cli/add_command.go:636–665  ·  view source on GitHub ↗
(destFile string, content string, fileExists bool, opts AddOptions, tracker *FileTracker)

Source from the content-addressed store, hash-verified

634}
635
636func trackAndWriteWorkflowFile(destFile string, content string, fileExists bool, opts AddOptions, tracker *FileTracker) error {
637 if tracker != nil {
638 if fileExists {
639 tracker.TrackModified(destFile)
640 } else {
641 tracker.TrackCreated(destFile)
642 }
643 }
644 if err := os.WriteFile(destFile, []byte(content), constants.FilePermSensitive); err != nil {
645 return fmt.Errorf("failed to write destination file '%s': %w", destFile, err)
646 }
647
648 // Read back the just-written file to ensure downstream processing (including
649 // frontmatter hash computation) uses the exact bytes on disk and avoids parity drift.
650 writtenContent, err := os.ReadFile(destFile)
651 if err != nil {
652 return fmt.Errorf("failed to read back destination file '%s': %w", destFile, err)
653 }
654 if !opts.Quiet {
655 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Added workflow: "+filepath.Base(destFile)))
656 if opts.Verbose {
657 if description := ExtractWorkflowDescription(string(writtenContent)); description != "" {
658 fmt.Fprintln(os.Stderr, "")
659 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(description))
660 fmt.Fprintln(os.Stderr, "")
661 }
662 }
663 }
664 return nil
665}
666
667// addActionWorkflowWithTracking installs a raw GitHub Actions YAML workflow file (.yml)
668// directly to the target directory without any frontmatter processing or compilation.

Callers 1

addWorkflowWithTrackingFunction · 0.85

Calls 6

FormatSuccessMessageFunction · 0.92
FormatInfoMessageFunction · 0.92
TrackModifiedMethod · 0.80
TrackCreatedMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected