Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions .github/workflows/PR-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ jobs:
contains(github.event.comment.body, '/gemini-review')
steps:
- name: PR Info
env:
#Assign untrusted inputs to environment variables first
COMMENT_BODY: ${{ github.event.comment.body }}
ISSUE_NUM: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
#Use shell variables ("$VAR") instead of template tags
run: |
echo "Comment: ${{ github.event.comment.body }}"
echo "Issue Number: ${{ github.event.issue.number }}"
echo "Repository: ${{ github.repository }}"
echo "Comment: $COMMENT_BODY"
echo "Issue Number: $ISSUE_NUM"
echo "Repository: $REPO"

- name: Checkout Repo
uses: actions/checkout@v3
Expand All @@ -30,17 +36,20 @@ jobs:

- name: Get PR Details
id: pr
run: |
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }})
echo "head_sha=$(echo $PR_JSON | jq -r .head.sha)" >> $GITHUB_OUTPUT
echo "base_sha=$(echo $PR_JSON | jq -r .base.sha)" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
ISSUE_NUM: ${{ github.event.issue.number }}
#Use env vars for the API call to prevent injection
#Use quotes around variables to prevent word splitting
run: |
PR_JSON=$(gh api "repos/$REPO/pulls/$ISSUE_NUM")
echo "head_sha=$(echo "$PR_JSON" | jq -r .head.sha)" >> $GITHUB_OUTPUT
echo "base_sha=$(echo "$PR_JSON" | jq -r .base.sha)" >> $GITHUB_OUTPUT

- uses: truongnh1992/gemini-ai-code-reviewer@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GEMINI_MODEL: gemini-2.5-flash
EXCLUDE: "*.md,*.txt,package-lock.json"

EXCLUDE: "*.md,*.txt,package-lock.json"