This action reviews code in pull requests using Gemini.
model
: The model to use for the code review. Default:gemini-1.5-pro-latest
.pull_request_diff
: The diff of the pull request.pull_request_chunk_size
: (Optional) The chunk size for review. Default:3500
.extra_prompt
: (Optional) Additional context for the review.log_level
: (Optional) Log level for the action. Default:DEBUG
.
review_comments
: Review comments from Gemini.
After having the 2 above keys, at the github repository, go to
Settings > Secrets and Variales > Actions > Add 2 new secret keys.
nname: "Review the code with Gemini"
on:
pull_request:
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: "Get diff of the pull request"
id: get_diff
shell: bash
env:
PULL_REQUEST_HEAD_REF: "${{ github.event.pull_request.head.ref }}"
PULL_REQUEST_BASE_REF: "${{ github.event.pull_request.base.ref }}"
run: |-
git fetch origin "${{ env.PULL_REQUEST_HEAD_REF }}"
git fetch origin "${{ env.PULL_REQUEST_BASE_REF }}"
git checkout "${{ env.PULL_REQUEST_HEAD_REF }}"
git diff "origin/${{ env.PULL_REQUEST_BASE_REF }}" > "diff.txt"
{
echo "pull_request_diff<<EOF";
cat "diff.txt";
echo 'EOF';
} >> $GITHUB_OUTPUT
- name: Review the code with Gemini
uses: bunheree/[email protected]
env: # Set environment variables here
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} # Pass the secret as an environment variable
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN_KEY }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
GIT_COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
with:
model: "gemini-1.5-pro-latest"
pull_request_diff: |-
${{ steps.get_diff.outputs.pull_request_diff }}
pull_request_chunk_size: "3500"
extra_prompt: ""
log_level: "DEBUG"