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

Function isCopilotWorkflowContent

pkg/cli/add_command.go:867–883  ·  view source on GitHub ↗

isCopilotWorkflowContent returns true when the workflow frontmatter declares engine: copilot. It is used to guard AddCopilotRequestsPermission injection so that the flag is only applied to Copilot workflows even when multiple workflows of different engines are processed together.

(content string)

Source from the content-addressed store, hash-verified

865// It is used to guard AddCopilotRequestsPermission injection so that the flag is only applied
866// to Copilot workflows even when multiple workflows of different engines are processed together.
867func isCopilotWorkflowContent(content string) bool {
868 lines, _, err := parseFrontmatterLines(content)
869 if err != nil {
870 return false
871 }
872 for _, line := range lines {
873 if !isTopLevelKey(line) {
874 continue
875 }
876 trimmed := strings.TrimSpace(line)
877 if parseYAMLMapKey(trimmed) == "engine" {
878 val := strings.TrimSpace(strings.TrimPrefix(trimmed, "engine:"))
879 return val == string(constants.CopilotEngine)
880 }
881 }
882 return false
883}
884
885// addCopilotRequestsPermissionToContent injects `permissions.copilot-requests: write`
886// into the workflow frontmatter, enabling GitHub Actions token auth for Copilot (org billing).

Callers 1

Calls 3

parseFrontmatterLinesFunction · 0.85
isTopLevelKeyFunction · 0.85
parseYAMLMapKeyFunction · 0.85

Tested by

no test coverage detected