Code Review by Gemini AI #191
This file contains 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
name: "Code Review by Gemini AI" | |
on: | |
issue_comment: | |
types: | |
- created | |
- updated | |
jobs: | |
review: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Only PR comments | |
if: ${{ !github.event.issue.pull_request || !contains(github.event.comment.body,'!ai') }} | |
run: exit 1 | |
- name: Put a reaction to the comment | |
run: gh api graphql --silent --raw-field query="mutation AddReaction {addReaction(input:{subjectId:\"$NODE_ID\",content:EYES}){reaction{content}subject{id}}}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_ID: ${{ github.event.comment.node_id }} | |
- name: Fetch PR diff using GitHub API | |
id: pr-diff | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const pr_number = context.payload.issue.number; | |
const { data: diff } = await github.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', { | |
headers: { | |
accept: 'application/vnd.github.v3.diff' | |
}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: pr_number | |
}); | |
return { diff }; | |
- name: Log diff | |
run: echo "${{steps.pr-diff.outputs.diff}}" | |
- uses: rubensflinco/[email protected] | |
name: "Code Review by Gemini AI" | |
continue-on-error: true | |
id: review | |
with: | |
gemini_api_key: ${{ secrets.GEMINI_API_KEY }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
github_repository: ${{ github.repository }} | |
github_pull_request_number: ${{ github.event.issue.number }} | |
model: "gemini-1.5-pro-latest" | |
pull_request_diff: |- | |
${{ steps.pr-diff.outputs.diff }} | |
pull_request_chunk_size: "3500" | |
extra_prompt: |- | |
Focus your review on code logic, security vulnerabilities, and potential improvements in these files. | |
log_level: "DEBUG" |