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)
| 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. |
| 867 | func 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). |
no test coverage detected