Repository navigation
fix: skip auto-fix when HEAD is not the commit that triggered the workflow (v3) - #530
Merged
Merged
Conversation
…kflow On events without a pull request (issue_comment, workflow_run, schedule, workflow_dispatch) the auto-fix commit is pushed to GITHUB_REF_NAME, which is usually the default branch. If the workflow checked out another commit there, such as a pull request's head, the push put that commit and its ancestors on the default branch along with the formatting commit. Only commit when HEAD is GITHUB_SHA on those events, and skip with a warning otherwise.
2bndy5
approved these changes
Nov 13, 2026
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.
The same change as #529, for the
v3.0.0-rc0branch (the commit is a clean cherry-pick). #529 has the full description.Summary
On events that carry no pull request (
issue_comment,workflow_run,schedule,workflow_dispatch), the auto-fix step pushesHEADtoGITHUB_REF_NAME, usually the default branch. If the workflow checked out another commit there, such as a pull request's head, that commit and its ancestors were pushed to the default branch together with the fix commit.Now auto-fix only commits when
HEADisGITHUB_SHAon those events, and is skipped with a warning otherwise.pushandpull_requestworkflows are not affected.Testing
Run on real runners in cpp-linter/test-cpp-linter-action with this branch (cpp-linter
2.0.0rc24, clang 18, ubuntu-latest). The stand-in for "a pull request's head is checked out" is an extra empty commit made afteractions/checkout.HEADahead ofGITHUB_SHAHEADisGITHUB_SHA(plain push)If you would rather pick this up when rebasing the branch onto
mainafter #529, feel free to close this one.