-
Notifications
You must be signed in to change notification settings - Fork 131
Add base-branch field for cross-repo PRs targeting non-default branches
#15089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
base-branch field for cross-repo PRs targeting non-default branches
|
@copilot Merge main and recompile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds support for configuring the base branch used by the create-pull-request safe output, enabling cross-repo PR creation targeting non-default branches while keeping the existing ${{ github.ref_name }} default.
Changes:
- Added
base-branchtoCreatePullRequestsConfigand propagate it into the create PR job env (GH_AW_BASE_BRANCH) and handler-manager config (base_branch). - Extended the workflow JSON schema to accept the new
base-branchfield. - Added unit + integration coverage to validate default vs custom base branch compilation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/create_pull_request_base_branch_integration_test.go | New integration tests that compile workflows and assert base_branch output for custom/default/slash-containing branches. |
| pkg/workflow/create_pull_request.go | Adds BaseBranch config field and uses it to set GH_AW_BASE_BRANCH, falling back to ${{ github.ref_name }}. |
| pkg/workflow/compiler_safe_outputs_config_test.go | Adds unit test verifying handler-manager config JSON includes the expected base_branch. |
| pkg/workflow/compiler_safe_outputs_config.go | Updates create_pull_request handler config builder to emit custom base_branch or default ${{ github.ref_name }}. |
| pkg/parser/schemas/main_workflow_schema.json | Adds base-branch to the create-pull-request schema definition. |
| docs/src/content/docs/reference/frontmatter-full.md | Documents the new base-branch option under safe-outputs.create-pull-request. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for _, step := range steps { | ||
| if strings.Contains(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG") { | ||
| parts := strings.Split(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: ") | ||
| if len(parts) == 2 { | ||
| jsonStr := strings.TrimSpace(parts[1]) | ||
| jsonStr = strings.Trim(jsonStr, "\"") | ||
| jsonStr = strings.ReplaceAll(jsonStr, "\\\"", "\"") | ||
|
|
||
| var config map[string]map[string]any | ||
| err := json.Unmarshal([]byte(jsonStr), &config) | ||
| require.NoError(t, err, "Config JSON should be valid") | ||
|
|
||
| prConfig, ok := config["create_pull_request"] | ||
| require.True(t, ok, "create_pull_request config should exist") | ||
|
|
||
| baseBranch, ok := prConfig["base_branch"] | ||
| require.True(t, ok, "base_branch should be in config") | ||
|
|
||
| assert.Equal(t, tt.expectedBaseBranch, baseBranch, "base_branch should match expected value") | ||
| } | ||
| } | ||
| } |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In TestCreatePullRequestBaseBranch, the JSON extraction loop doesn’t assert that it actually found/parses the GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG line. If the env var generation regresses (or the string format changes), the test can pass without validating anything. Track a found boolean (or extract once with SplitN) and require.True(t, found, ...) after the loop, and consider failing if len(parts) != 2 to avoid silent success.
| for _, step := range steps { | |
| if strings.Contains(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG") { | |
| parts := strings.Split(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: ") | |
| if len(parts) == 2 { | |
| jsonStr := strings.TrimSpace(parts[1]) | |
| jsonStr = strings.Trim(jsonStr, "\"") | |
| jsonStr = strings.ReplaceAll(jsonStr, "\\\"", "\"") | |
| var config map[string]map[string]any | |
| err := json.Unmarshal([]byte(jsonStr), &config) | |
| require.NoError(t, err, "Config JSON should be valid") | |
| prConfig, ok := config["create_pull_request"] | |
| require.True(t, ok, "create_pull_request config should exist") | |
| baseBranch, ok := prConfig["base_branch"] | |
| require.True(t, ok, "base_branch should be in config") | |
| assert.Equal(t, tt.expectedBaseBranch, baseBranch, "base_branch should match expected value") | |
| } | |
| } | |
| } | |
| found := false | |
| for _, step := range steps { | |
| if strings.Contains(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG") { | |
| parts := strings.SplitN(step, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: ", 2) | |
| require.Len(t, parts, 2, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG line should contain key and value") | |
| found = true | |
| jsonStr := strings.TrimSpace(parts[1]) | |
| jsonStr = strings.Trim(jsonStr, "\"") | |
| jsonStr = strings.ReplaceAll(jsonStr, "\\\"", "\"") | |
| var config map[string]map[string]any | |
| err := json.Unmarshal([]byte(jsonStr), &config) | |
| require.NoError(t, err, "Config JSON should be valid") | |
| prConfig, ok := config["create_pull_request"] | |
| require.True(t, ok, "create_pull_request config should exist") | |
| baseBranch, ok := prConfig["base_branch"] | |
| require.True(t, ok, "base_branch should be in config") | |
| assert.Equal(t, tt.expectedBaseBranch, baseBranch, "base_branch should match expected value") | |
| } | |
| } | |
| require.True(t, found, "GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG should be present in steps") |
Add documentation for the new base-branch configuration option in the create-pull-request safe output. This field allows workflows to specify which branch a pull request should target, particularly useful for cross-repository workflows targeting non-default branches. Changes: - Add base-branch field to create-pull-request YAML example - Document default behavior (defaults to github.ref_name) - Include use case example for cross-repo PR targeting vnext branch Related: #15089 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implementation Complete ✅
Successfully merged main branch and recompiled all workflows with both
base-branchandfooterfields working together.Changes Made
Merge Conflicts Resolved:
BaseBranchandFooterfields inCreatePullRequestsConfigstructValidation:
Usage Example
Both fields can now be used together:
Compiles to:
{ "create_pull_request": { "base_branch": "vnext", "footer": false, "target-repo": "microsoft/vscode-docs", "draft": true } }Backward Compatibility
Both fields maintain backward compatibility:
base-branchdefaults to${{ github.ref_name }}when not specifiedfooterdefaults totruewhen not specifiedOriginal prompt
base-branchfield for cross-repo PRs targeting non-default branches #15075💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.