reconstructWorkflowFileFromMap reconstructs a workflow file from frontmatter map and markdown using proper field ordering and YAML helpers
(frontmatter map[string]any, markdown string)
| 132 | // reconstructWorkflowFileFromMap reconstructs a workflow file from frontmatter map and markdown |
| 133 | // using proper field ordering and YAML helpers |
| 134 | func reconstructWorkflowFileFromMap(frontmatter map[string]any, markdown string) (string, error) { |
| 135 | // Convert frontmatter to YAML with proper field ordering |
| 136 | // Use PriorityWorkflowFields to ensure consistent ordering of top-level fields |
| 137 | updatedFrontmatter, err := workflow.MarshalWithFieldOrder(frontmatter, constants.PriorityWorkflowFields) |
| 138 | if err != nil { |
| 139 | return "", fmt.Errorf("failed to marshal frontmatter: %w", err) |
| 140 | } |
| 141 | |
| 142 | // Clean up the YAML - remove trailing newline and unquote the "on" key |
| 143 | frontmatterStr := strings.TrimSuffix(string(updatedFrontmatter), "\n") |
| 144 | frontmatterStr = workflow.UnquoteYAMLKey(frontmatterStr, "on") |
| 145 | |
| 146 | return parser.ReconstructWorkflowFile(frontmatterStr, markdown) |
| 147 | } |
| 148 | |
| 149 | // processIncludesWithWorkflowSpec processes @include directives in content and replaces local file references |
| 150 | // with workflowspec format (owner/repo/path@sha) for all includes found in the package. |
no test coverage detected