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

Function reconstructWorkflowFileFromMap

pkg/cli/imports.go:134–147  ·  view source on GitHub ↗

reconstructWorkflowFileFromMap reconstructs a workflow file from frontmatter map and markdown using proper field ordering and YAML helpers

(frontmatter map[string]any, markdown string)

Source from the content-addressed store, hash-verified

132// reconstructWorkflowFileFromMap reconstructs a workflow file from frontmatter map and markdown
133// using proper field ordering and YAML helpers
134func 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.

Callers 2

Calls 4

MarshalWithFieldOrderFunction · 0.92
UnquoteYAMLKeyFunction · 0.92
ReconstructWorkflowFileFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected