dsyme says:
I'm not sure an earlier fixto use github.ref_name was totally right, but it's partly a spec question.
create-pull-request says the default target base branch is github.ref_name.
base-branch: "vnext" # target branch for PR (default: github.ref_name)
However when invoked in the context of a PR sometimes github.ref_name appears to be whacky, like 17482/merge meaning something about merging the PR17481 or something. Our processing code doesn't expect this and it can't be used for
agent says:
GitHub Copilot: I need to investigate this GitHub Actions context variable issue. Let me search for relevant documentation and usage patterns.
Searched for regex github\.ref_name|github\.base_ref|github\.head_ref (**/*.{go,md,cjs}), 38 results
Searched for regex refs/pull.*merge|pull request context|PR context (**/*.md), 18 results
Searched for files matching **/create_pull_request*.{md,cjs}, 2 matches
Let me read the scratchpad file that seems to explain this exact issue:
Read , lines 1 to 300
Read , lines 1 to 100
Now let me search for how GitHub Actions context variables work and what the best practices are:
Searched for regex github\.event_name|pull_request_target|issue_comment (**/*.{md,yaml,yml}), 20 results
Read , lines 670 to 720
Now let me check what GitHub's official documentation says about these context variables:
Searched for regex base_ref.*available|head_ref.*available|ref_name.*pull request (**/*.md), 1 result
Read , lines 1 to 100
Let me also check the compiler_safe_outputs_config.go file to see all the places where this needs to be fixed:
Read , lines 440 to 480
Investigation Results
You're absolutely right to be concerned. Using github.ref_name as the default is broken for PR contexts.
The Problem
What github.ref_name contains:
| Event Type |
github.ref_name Value |
Valid for checkout? |
| push |
"main" or "feature-branch" |
✅ Yes |
| pull_request |
"123/merge" (from refs/pull/123/merge) |
❌ No |
| pull_request_target |
"123/merge" |
❌ No |
| issue_comment on PR |
Varies, often "123/merge" |
❌ No |
Why "123/merge" breaks:
- It's a temporary merge ref created by GitHub, not a real branch name
- Cannot be used for
git checkout or git push
- Cannot be used as a target
base-branch for creating PRs
- Causes errors like:
remote ref does not exist, workflow file changed, etc.
The Solution
Use a conditional expression that works for both PR and push contexts:
${{ github.base_ref || github.ref_name }}
How it works:
- PR events:
github.base_ref is set (e.g., "main") → use it ✅
- Push events:
github.base_ref is empty → fallback to github.ref_name ✅
Files That Need Fixing
I found three locations where this needs to be corrected:
- compiler_safe_outputs_steps.go (checkout ref)
- create_pull_request.go (GH_AW_BASE_BRANCH env var)
- compiler_safe_outputs_config.go (handler config defaults - appears twice)
Would you like me to implement the fix across all these locations?
dsyme says:
I'm not sure an earlier fixto use github.ref_name was totally right, but it's partly a spec question.
create-pull-request says the default target base branch is github.ref_name.
However when invoked in the context of a PR sometimes github.ref_name appears to be whacky, like 17482/merge meaning something about merging the PR17481 or something. Our processing code doesn't expect this and it can't be used for
agent says:
GitHub Copilot: I need to investigate this GitHub Actions context variable issue. Let me search for relevant documentation and usage patterns.
Searched for regex
github\.ref_name|github\.base_ref|github\.head_ref(**/*.{go,md,cjs}), 38 resultsSearched for regex
refs/pull.*merge|pull request context|PR context(**/*.md), 18 resultsSearched for files matching
**/create_pull_request*.{md,cjs}, 2 matchesLet me read the scratchpad file that seems to explain this exact issue:
Read , lines 1 to 300
Read , lines 1 to 100
Now let me search for how GitHub Actions context variables work and what the best practices are:
Searched for regex
github\.event_name|pull_request_target|issue_comment(**/*.{md,yaml,yml}), 20 resultsRead , lines 670 to 720
Now let me check what GitHub's official documentation says about these context variables:
Searched for regex
base_ref.*available|head_ref.*available|ref_name.*pull request(**/*.md), 1 resultRead , lines 1 to 100
Let me also check the compiler_safe_outputs_config.go file to see all the places where this needs to be fixed:
Read , lines 440 to 480
Investigation Results
You're absolutely right to be concerned. Using
github.ref_nameas the default is broken for PR contexts.The Problem
What
github.ref_namecontains:github.ref_nameValue"main"or"feature-branch""123/merge"(fromrefs/pull/123/merge)"123/merge""123/merge"Why "123/merge" breaks:
git checkoutorgit pushbase-branchfor creating PRsremote ref does not exist,workflow file changed, etc.The Solution
Use a conditional expression that works for both PR and push contexts:
${{ github.base_ref || github.ref_name }}How it works:
github.base_refis set (e.g., "main") → use it ✅github.base_refis empty → fallback togithub.ref_name✅Files That Need Fixing
I found three locations where this needs to be corrected:
Would you like me to implement the fix across all these locations?