Skip to content

Commit 340b037

Browse files
committed
fix(ci): push lint fixes to branch ref instead of detached HEAD
actions/checkout on pull_request events checks out the merge commit, leaving the runner in detached HEAD state. A plain 'git push' then fails with exit 128 because there is no active branch to push to. Fix: use 'git push origin HEAD:${HEAD_REF}' when github.head_ref is set (PR context), falling back to plain 'git push' on direct pushes to main where HEAD is always attached.
1 parent 64ede0f commit 340b037

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,24 @@ jobs:
4848
if: |
4949
!contains(github.actor, 'dependabot') &&
5050
(github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner)
51+
env:
52+
HEAD_REF: ${{ github.head_ref }}
5153
run: |
5254
git config user.name "github-actions[bot]"
5355
git config user.email "github-actions[bot]@users.noreply.github.com"
54-
git diff --quiet || (git add -A && git commit -m "chore(lint): biome auto-fix" && git push)
56+
# actions/checkout leaves a detached HEAD on PR events; push back
57+
# to the source branch explicitly using HEAD_REF when available.
58+
if git diff --quiet; then
59+
echo "No lint fixes needed."
60+
else
61+
git add -A
62+
git commit -m "chore(lint): biome auto-fix"
63+
if [ -n "$HEAD_REF" ]; then
64+
git push origin "HEAD:${HEAD_REF}"
65+
else
66+
git push
67+
fi
68+
fi
5569
5670
smoke:
5771
name: Smoke Test

0 commit comments

Comments
 (0)