Skip to content

bunheree/gemini-review

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Pull Request with Gemini API

WTM Latest Stable Version License

This action reviews code in pull requests using Gemini.

Inputs

  • 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.

Outputs

  • review_comments: Review comments from Gemini.

Review - comment PR

Example Usage

1. Create GEMINI_API_KEY and GIT_TOKEN_KEY

After having the 2 above keys, at the github repository, go to

Settings > Secrets and Variales > Actions > Add 2 new secret keys.

Example Usage

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"

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Packages

No packages published