Support org-wide GitHub App tokens via wildcard repositories#16430
Support org-wide GitHub App tokens via wildcard repositories#16430
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot update docs |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Documentation updated in commit 25ad2f6. Added repository scoping options to:
All docs now document the three scoping modes:
|
There was a problem hiding this comment.
Pull request overview
Adds support for organization-wide GitHub App installation tokens by allowing repositories: ["*"] in config, which compiles to an actions/create-github-app-token step that omits the repositories input (enabling org-wide access in the installation).
Changes:
- Update GitHub App token step generation to treat
repositories: ["*"]as a special case and omit therepositoriesfield. - Add unit tests covering org-wide token behavior for both safe-outputs and the GitHub MCP tool.
- Update reference docs and multi-repo patterns to document the three repository-scoping modes.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/safe_outputs_app.go | Implements wildcard handling by omitting repositories when configured as ["*"]. |
| pkg/workflow/safe_outputs_app_test.go | Adds a test ensuring wildcard config results in no repositories: emitted for safe-outputs token minting. |
| pkg/workflow/github_mcp_app_token_test.go | Adds a test ensuring wildcard config results in no repositories: emitted for GitHub MCP token minting. |
| docs/src/content/docs/reference/tools.md | Documents repositories scoping options for the GitHub tool’s app token config. |
| docs/src/content/docs/reference/safe-outputs.md | Documents repositories scoping options for safe-outputs app config. |
| docs/src/content/docs/reference/frontmatter-full.md | Updates schema documentation to reflect the three supported repository scoping modes. |
| docs/src/content/docs/patterns/multirepoops.md | Adds an org-wide GitHub App token example for multi-repo operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // - If repositories is specified with values, use those specific repos | ||
| // - If repositories is empty/not specified, default to current repository | ||
| if len(app.Repositories) == 1 && app.Repositories[0] == "*" { | ||
| // Org-wide access: omit repositories field entirely | ||
| safeOutputsAppLog.Print("Using org-wide GitHub App token (repositories: *)") |
There was a problem hiding this comment.
repositories treats "" specially only when it is the sole entry. If a user configures repositories: ["*", "repo1"], this will currently emit repositories: *,repo1 which is unlikely to be accepted by actions/create-github-app-token and won’t produce org-wide access. Consider validating that "" cannot be combined with other repository names (return a clear error) to avoid generating an invalid workflow.
| // - If repositories is specified with values, use those specific repos | |
| // - If repositories is empty/not specified, default to current repository | |
| if len(app.Repositories) == 1 && app.Repositories[0] == "*" { | |
| // Org-wide access: omit repositories field entirely | |
| safeOutputsAppLog.Print("Using org-wide GitHub App token (repositories: *)") | |
| // - If repositories contains "*" along with other entries, treat this as invalid, | |
| // log a clear message, and fall back to org-wide access (omit the field) | |
| // - If repositories is specified with values (and does not contain "*"), use those specific repos | |
| // - If repositories is empty/not specified, default to current repository | |
| hasStar := false | |
| for _, r := range app.Repositories { | |
| if r == "*" { | |
| hasStar = true | |
| break | |
| } | |
| } | |
| if hasStar { | |
| if len(app.Repositories) == 1 { | |
| // Org-wide access: omit repositories field entirely | |
| safeOutputsAppLog.Print("Using org-wide GitHub App token (repositories: *)") | |
| } else { | |
| // Invalid configuration: "*" combined with other repositories | |
| safeOutputsAppLog.Print("Invalid GitHub App repositories configuration: '*' cannot be combined with other repositories; using org-wide access instead") | |
| } |
Support for org-wide GitHub App tokens
This PR implements support for organization-wide GitHub App tokens by allowing users to specify
"*"in therepositoriesfield.Implementation Plan
pkg/workflow/safe_outputs_app.gobuildGitHubAppTokenMintStep()to handle"*"wildcardChanges Made
Core Changes:
pkg/workflow/safe_outputs_app.goto detectrepositories: ["*"]and omit therepositoriesfield from the generated GitHub Action step, enabling org-wide accessrepositoriesis not specified, it defaults to the current repositoryTest Coverage:
TestSafeOutputsAppTokenOrgWideto verify org-wide token generation for safe-outputsTestGitHubMCPAppTokenOrgWideto verify org-wide token generation for GitHub MCP serverDocumentation:
docs/src/content/docs/reference/safe-outputs.mdwith repository scoping optionsdocs/src/content/docs/reference/tools.mdwith repository scoping optionsdocs/src/content/docs/reference/frontmatter-full.mdwith accurate descriptionsdocs/src/content/docs/patterns/multirepoops.mdUsage Examples
Org-wide access (NEW):
Generated action step omits the
repositoriesfield for org-wide access.Current repository (default):
Generated action step includes:
repositories: ${{ github.event.repository.name }}Specific repositories:
Generated action step includes:
repositories: repo1,repo2Security Summary
✅ No security vulnerabilities detected by CodeQL
✅ No issues found in code review
✅ All tests passing
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.