Skip to content

Commit e07a152

Browse files
committed
refactor: improve PR checkout logic in Gemini review workflow using dedicated step
1 parent 02c6bfb commit e07a152

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/gemini-pr-review.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@ jobs:
4141
echo "Contains @gemini: ${{ contains(github.event.comment.body, '@gemini') }}"
4242
echo "Comment author: ${{ github.event.comment.user.login }}"
4343
44+
- name: Determine checkout ref
45+
id: checkout_ref
46+
run: |
47+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
48+
echo "ref=refs/pull/${{ github.event.issue.number }}/head" >> "$GITHUB_OUTPUT"
49+
else
50+
echo "ref=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_OUTPUT"
51+
fi
52+
4453
- name: Checkout PR code
4554
uses: actions/checkout@v4
4655
with:
4756
token: ${{ steps.generate_token.outputs.token }}
48-
ref: ${{ github.event_name == 'issue_comment' && 'refs/pull/${{ github.event.issue.number }}/head' || github.event.pull_request.head.sha }}
57+
ref: ${{ steps.checkout_ref.outputs.ref }}
4958
fetch-depth: 0
5059

5160
- name: Get PR details

0 commit comments

Comments
 (0)