diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index d0faf0711..4f1c143d2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -53,11 +53,17 @@ jobs: if ! git diff --exit-code || [ -n "$(git ls-files --others --exclude-standard)" ]; then git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" + + # Ensure we're on the correct branch + git checkout -B ${{ github.head_ref }} git add -A git commit -m "Apply pre-commit fixes" - # push to the PR branch - git push origin HEAD:${{ github.head_ref }} + # Pull latest changes from the PR branch and rebase our commit on top + git pull --rebase origin ${{ github.head_ref }} + + # Push to the PR branch + git push origin ${{ github.head_ref }} echo "Pre-commit fixes committed and pushed" else echo "No changes to commit"