Add top-level github-app frontmatter as universal fallback for token minting#21510
Add top-level github-app frontmatter as universal fallback for token minting#21510
github-app frontmatter as universal fallback for token minting#21510Conversation
…oken minting Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
github-app frontmatter as universal fallback for token minting
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 3d9dc56. The top-level The workflow's own top-level Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
Adds support for a top-level github-app frontmatter key that serves as a universal fallback for GitHub App token minting across workflow sections, reducing repeated configuration.
Changes:
- Extend the main workflow schema to allow top-level
github-app. - Extract/store top-level GitHub App config in
WorkflowDataand apply it as a fallback to activation, safe-outputs, checkout, tools.github, and APM dependencies. - Add integration tests plus sample workflow fixtures demonstrating each fallback/precedence scenario.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/top_level_github_app_integration_test.go | New integration tests validating top-level fallback behavior and precedence. |
| pkg/workflow/compiler_types.go | Adds TopLevelGitHubApp field to workflow compilation state. |
| pkg/workflow/compiler_orchestrator_workflow.go | Implements extraction + fallback application across nested token-minting consumers. |
| pkg/parser/schemas/main_workflow_schema.json | Adds top-level github-app to the frontmatter schema. |
| pkg/cli/workflows/test-top-level-github-app-*.md | Adds sample workflows used as scenario fixtures for integration tests/docs. |
Comments suppressed due to low confidence (2)
pkg/workflow/compiler_orchestrator_workflow.go:599
- The top-level github-app fallback is applied to activation whenever ActivationGitHubApp is nil, but this ignores an explicit on.github-token. If a workflow sets on.github-token (and no on.github-app), applying the top-level github-app changes auth precedence and will cause the pre-activation/activation steps to prefer an app token over the user-specified token. Update the fallback condition to only apply when both ActivationGitHubApp is nil AND ActivationGitHubToken is empty (i.e., no explicit activation auth configured).
if importsResult != nil && importsResult.MergedTopLevelGitHubApp != "" {
var appMap map[string]any
if err := json.Unmarshal([]byte(importsResult.MergedTopLevelGitHubApp), &appMap); err == nil {
app := parseAppConfig(appMap)
if app.AppID != "" && app.PrivateKey != "" {
pkg/workflow/compiler_orchestrator_workflow.go:605
- The safe-outputs fallback currently applies whenever SafeOutputs.GitHubApp is nil, even if SafeOutputs.GitHubToken is explicitly set. Because downstream logic prioritizes GitHubApp over GitHubToken, this would silently override a user-provided safe-outputs.github-token when a top-level github-app exists. Only apply the top-level fallback when neither safe-outputs.github-app nor safe-outputs.github-token is configured.
return app
}
}
}
return nil
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| if data.ParsedTools != nil && data.ParsedTools.GitHub != nil && data.ParsedTools.GitHub.GitHubApp == nil { | ||
| orchestratorWorkflowLog.Print("Applying top-level github-app fallback for tools.github") | ||
| data.ParsedTools.GitHub.GitHubApp = fallback | ||
| // Also update the raw tools map so applyDefaultTools (called from applyDefaults in | ||
| // processOnSectionAndFilters) does not lose the fallback when it rebuilds ParsedTools | ||
| // from the map. | ||
| if github, ok := data.Tools["github"].(map[string]any); ok { |
| "app-id: ${{ vars.SAFE_OUTPUTS_APP_ID }}", | ||
| "app-id: ${{ vars.ACTIVATION_APP_ID }}", | ||
| }, | ||
| }, |
|
@copilot Review comments |
…test entry Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 8ade6cb. Addressed both review comments:
Also added the missing MCP entry to |
|
@copilot Keep working |
|
@copilot keep working |
|
@copilot keep working |
…plicitly disabled Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed an additional edge case in ac43855: when Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot add more tests for each possible override |
…fix activation and safe-outputs github-token skip guards Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in b426ffd. Added 12 new unit tests covering all five fallback targets (activation, safe-outputs, checkout, tools.github, dependencies) with three variants each: fallback applied, section-specific override wins, and explicit token skips the fallback. Also fixed two related bugs uncovered while writing the tests:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot create helper function to determine if global overuse is needed and apply at every if state that does the override so that the behavior is consistent |
…ll five fallback sites Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in a9c5c39. Extracted |
* docs: add GH_HOST and RUNNER_TEMP to glossary (daily scan 2026-03-18) (#21553) * docs: update GHES CLI docs and add Copilot GHES troubleshooting guide (#21528) * Fix list height not updating on terminal resize (#21555) * fix(daily-workflow-updater): unblock PR creation by setting protected-files: allowed (#21554) * chore: bump MCP Gateway v0.1.15→v0.1.17 (#21552) * feat: custom Huh theme mapped from pkg/styles Dracula palette (#21557) * Add top-level `github-app` frontmatter as universal fallback for token minting (#21510) * feat: add GitHub App-only permissions support (#21511) * fix: fall back to existing remote tracking ref when incremental patch fetch fails (#21568) * Add weekly blog post writer agentic workflow (#21575) * ci: add timeout-minutes to all 25 jobs lacking explicit limits (#21601) * fix: add setupGlobals in generate_aw_info step to fix staged mode ReferenceError (#21602) * Disable lockdown mode for weekly blog post generator (#21598) * fix: replace git push with GraphQL signed commits to satisfy required_signatures rulesets (#21576) * docs: add weekly update blog post for 2026-03-18 (#21608) Covers v0.58.0 through v0.61.0 (7 releases this week), notable PRs, and auto-triage-issues as Agent of the Week. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix failing CI: merge main to include setupGlobals in generate_aw_info step and update golden files Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…ains on data residency (#21527) * Initial plan * Fix threat detection AWF run missing --copilot-api-target and GHE domains on data residency When engine.api-target is configured for GHE Cloud with data residency, propagate the APITarget from the main engine config to the detection engine config so the threat detection AWF invocation receives the same --copilot-api-target flag and GHE-specific domains in --allow-domains. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Add GITHUB_COPILOT_BASE_URL env var support and fix integration test api-target - Fix TestAPITargetDomainsInThreatDetectionStep to use api.contoso-aw.ghe.com (copilot-api. prefix does not trigger base-domain derivation in GetAPITargetDomains) - Add GetCopilotAPITarget() helper: resolves --copilot-api-target from engine.api-target (explicit) or GITHUB_COPILOT_BASE_URL in engine.env (fallback), mirroring the OPENAI_BASE_URL/ANTHROPIC_BASE_URL pattern for Codex/Claude - Update awf_helpers.go, copilot_engine_execution.go, and domains.go to use the helper - Add unit tests for GetCopilotAPITarget and engine execution step - Add integration test TestGitHubCopilotBaseURLInCompiledWorkflow - Update engines.md docs to document GITHUB_COPILOT_BASE_URL Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> * Update DefaultMCPGatewayVersion to v0.1.17 and regenerate golden/lock files (#21609) Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> * fix: merge main to resolve failing build-wasm and test CI jobs (#21612) * docs: add GH_HOST and RUNNER_TEMP to glossary (daily scan 2026-03-18) (#21553) * docs: update GHES CLI docs and add Copilot GHES troubleshooting guide (#21528) * Fix list height not updating on terminal resize (#21555) * fix(daily-workflow-updater): unblock PR creation by setting protected-files: allowed (#21554) * chore: bump MCP Gateway v0.1.15→v0.1.17 (#21552) * feat: custom Huh theme mapped from pkg/styles Dracula palette (#21557) * Add top-level `github-app` frontmatter as universal fallback for token minting (#21510) * feat: add GitHub App-only permissions support (#21511) * fix: fall back to existing remote tracking ref when incremental patch fetch fails (#21568) * Add weekly blog post writer agentic workflow (#21575) * ci: add timeout-minutes to all 25 jobs lacking explicit limits (#21601) * fix: add setupGlobals in generate_aw_info step to fix staged mode ReferenceError (#21602) * Disable lockdown mode for weekly blog post generator (#21598) * fix: replace git push with GraphQL signed commits to satisfy required_signatures rulesets (#21576) * docs: add weekly update blog post for 2026-03-18 (#21608) Covers v0.58.0 through v0.61.0 (7 releases this week), notable PRs, and auto-triage-issues as Agent of the Week. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix failing CI: merge main to include setupGlobals in generate_aw_info step and update golden files Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Workflows with multiple sections requiring GitHub App tokens (safe-outputs, checkout, MCP, APM dependencies, activation) had to repeat the same
github-appconfig in each section. This adds a single top-levelgithub-appfield that propagates as a fallback to all nested token minting operations.Fallback precedence
Section-specific
github-appalways wins; top-level is used only when the section has no explicit config. Explicitgithub-tokensettings also take priority and suppress the fallback:on.github-app/on.github-token— activation (reactions, status comments, skip-if)safe-outputs.github-app/safe-outputs.github-tokencheckout.github-app/checkout.github-token— entries without explicit authtools.github.github-app/tools.github.github-token— GitHub MCP server;tools.github: falsealso suppresses the fallbackdependencies.github-app— APM packagesUsage
The top-level
github-appcan also be defined in a shared agent workflow and imported by consuming workflows. The same first-wins precedence applies: the current workflow's owngithub-apptakes priority over one imported from a shared workflow.Implementation
github-appto top-level properties inmain_workflow_schema.jsonWorkflowData— newTopLevelGitHubApp *GitHubAppConfigfieldresolveTopLevelGitHubApp()— resolves the top-level config from frontmatter, falling back toMergedTopLevelGitHubAppfrom imports (same pattern asresolveActivationGitHubApp)applyTopLevelGitHubAppFallbacks()— called at end ofextractAdditionalConfigurations; patches both the typed struct fields and the rawtoolsmap (necessary becauseapplyDefaultsrebuildsParsedToolsfrom the map); skips each section when an explicitgithub-tokenorgithub-appis already set, and skipstools.githubwhen it is explicitly disabled (github: false)importAccumulatornow extracts the top-levelgithub-appfrom each imported workflow (first-wins); result surfaced viaImportsResult.MergedTopLevelGitHubAppvalidateGitHubAppJSON()— shared helper extracted to avoid duplicating required-field validation betweenextractOnGitHubAppandextractTopLevelGitHubAppTests
Six scenario workflow files in
pkg/cli/workflows/(one per fallback target + one showing section-specific precedence), with corresponding integration tests inpkg/workflow/top_level_github_app_integration_test.go. Unit tests inpkg/workflow/top_level_github_app_import_test.gocover all five fallback targets × three variants each (fallback applied, section-specific override wins, explicit token suppresses fallback), plus import scenarios (import fallback, local override, activation propagation).Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.