Skip to content

Commit 67f20c6

Browse files
authored
Update comment-to-commit-using-aider.yml
1 parent 2536ab0 commit 67f20c6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.github/workflows/comment-to-commit-using-aider.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,31 @@ jobs:
2828
runs-on: ubuntu-latest
2929
if: ${{ contains(github.event.comment.body, 'revert last commit') }}
3030
steps:
31-
- name: Checkout repository
31+
- name: Checkout branch
3232
uses: actions/checkout@v3
3333
with:
34-
ref: ${{ github.head_ref }}
35-
34+
ref: ${{ github.head_ref || github.ref }}
35+
3636
- name: Set up Git user configuration
3737
run: |
3838
git config user.name "github-actions"
3939
git config user.email "github-actions@github.com"
40-
40+
4141
- name: Revert last commit
4242
run: |
4343
LAST_COMMIT=$(git rev-parse HEAD)
4444
echo "Reverting commit: $LAST_COMMIT"
4545
git revert --no-edit $LAST_COMMIT
46-
46+
4747
- name: Push changes
4848
env:
4949
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5050
run: |
51-
git push origin HEAD:${{ github.head_ref }}
51+
# Determine branch using GITHUB_HEAD_REF if set (for PRs), else derive from GITHUB_REF
52+
if [ -n "$GITHUB_HEAD_REF" ]; then
53+
BRANCH="$GITHUB_HEAD_REF"
54+
else
55+
BRANCH="${GITHUB_REF#refs/heads/}"
56+
fi
57+
echo "Pushing changes to branch: $BRANCH"
58+
git push origin HEAD:"$BRANCH"

0 commit comments

Comments
 (0)