(destFile string, content string, fileExists bool, opts AddOptions, tracker *FileTracker)
| 634 | } |
| 635 | |
| 636 | func 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. |
no test coverage detected