fix: use PR head branch for rules-ref instead of merge ref#168
Merged
scottschreckengaust merged 1 commit intomainfrom Apr 2, 2026
Merged
fix: use PR head branch for rules-ref instead of merge ref#168scottschreckengaust merged 1 commit intomainfrom
scottschreckengaust merged 1 commit intomainfrom
Conversation
For pull_request events, CodeBuild runs in detached HEAD so git symbolic-ref fails. The fallback was GH_REF_NAME which resolves to '155/merge' — a virtual GitHub ref that cannot be cloned as a branch. Pass github.head_ref into the buildspec as GH_HEAD_REF and prefer it in the fallback chain so the evaluator clones the actual PR source branch.
Kalindi-Dev
added a commit
that referenced
this pull request
Apr 2, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the CodeBuild evaluation pipeline failing on PR builds because
--rules-refreceives155/merge(a virtual GitHub merge ref) instead of the actual PR source branch name. The evaluator'ssetup_rules()tries togit clone --branch 155/mergewhich fails because that ref doesn't exist as a cloneable branch.Changes
github.head_refinto the CodeBuild buildspec asGH_HEAD_REFenvironment variableCURRENT_BRANCHfallback chain from${GH_REF_NAME:-}to${GH_HEAD_REF:-${GH_REF_NAME:-}}so PR builds use the actual source branch namefix/some-feature155/merge(fails to clone)fix/some-featuremainmain(unchanged)v0.1.7v0.1.7(unchanged)User experience
Before: Every PR-triggered CodeBuild run fails at Stage 1 with
RuntimeError: Failed to clone AIDLC rules repo: fatal: Remote branch 155/merge not found in upstream origin.After: PR builds correctly resolve the source branch and clone the rules at the PR's head ref.
Checklist
Test Plan
CURRENT_BRANCHresolves to the PR head branch (notN/merge)CURRENT_BRANCHcorrectlyCURRENT_BRANCHcorrectlyAcknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.