fix(codex): checkout and push to PR branch instead of main#122
Conversation
The reusable Codex workflow was checking out the default branch (main) and trying to push there, which fails for workflow_run events on PRs. Changes: - Added pr_ref input to reusable-codex-run.yml to specify the target branch - Updated checkout to use pr_ref if provided - Updated push to target the correct branch - Updated keepalive_loop.js to return prRef from PR data - Updated agents-keepalive-loop.yml to pass pr_ref to Codex workflow This ensures Codex changes are pushed to the PR branch, not main.
Automated Status SummaryHead SHA: 2ac348d
Coverage Overview
Coverage Trend
Updated automatically; will refresh on subsequent CI/Docker completions. Keepalive checklistScopeNo scope information available Tasks
Acceptance criteria
|
🤖 Keepalive Loop StatusPR #122 | Iteration 0/5 Current State
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical issue where Codex changes were being pushed to the protected main branch instead of the PR branch, causing GH013 repository rule violations. The fix adds proper branch tracking through the workflow chain.
Key changes:
- Added
pr_refinput parameter to the reusable Codex workflow to accept the target branch - Updated the keepalive evaluation script to extract and return the PR's head branch reference
- Modified the checkout and push logic to use the PR branch when available, with appropriate fallbacks
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
.github/workflows/reusable-codex-run.yml |
Added pr_ref input parameter, updated checkout to use PR branch, and modified push logic to target the correct branch instead of defaulting to main |
.github/workflows/agents-keepalive-loop.yml |
Added pr_ref to job outputs and passed it through to the Codex workflow |
.github/scripts/keepalive_loop.js |
Extracted and returned the PR head branch reference from the GitHub API response |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| default: '' | ||
| type: string | ||
| pr_ref: | ||
| description: 'The branch/ref to checkout and push to (e.g., refs/heads/feature-branch).' |
There was a problem hiding this comment.
The description states that the expected format is refs/heads/feature-branch, but the actual value being passed from the JavaScript code is just the branch name without the refs/heads/ prefix. While the checkout action can handle both formats, the description should be updated to reflect the actual format being used for clarity and accuracy. Consider updating the example to just feature-branch to match the implementation.
| description: 'The branch/ref to checkout and push to (e.g., refs/heads/feature-branch).' | |
| description: 'The branch to checkout and push to (e.g., feature-branch).' |
Summary
Fixes the critical issue where Codex changes were being pushed to
maininstead of the PR branch.Problem
When the Keepalive loop runs Codex via
workflow_runtrigger:github.refisrefs/heads/main(the branch of the completed workflow)mainSolution
pr_refinput toreusable-codex-run.ymlpr_refif providedkeepalive_loop.jsto returnprReffrom PR dataagents-keepalive-loop.ymlto passpr_refto the Codex workflowTesting
This will fix the failing Keepalive runs on PR #103 where Codex was making changes but failing to push them.
Refs: #103
Automated Status Summary
Scope
reusable-codex-run.yml) completes iterations, there's no visibility into:Tasks
reusable-codex-run.ymlto emit structured outputs:final-messagefrom Codex actionfiles-changed(count of modified files)commits-pushed(boolean)<!-- codex-cli-status:start -->/<!-- codex-cli-status:end -->markersagents_pr_meta_update_body.jsto populate the new section:keepalive_loop.jsto pass iteration context to the summary:Acceptance criteria
Head SHA: ce6ef18
Latest Runs: ✅ success — Gate
Required: gate: ✅ success