Skip to content

Review Pull Request auto

Actions
Automatically Review Pull Request with Gemini API
v1.0.2
Latest
Star (9)

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/gemini-review@v1.0.2
        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"

Review Pull Request auto is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Automatically Review Pull Request with Gemini API
v1.0.2
Latest

Review Pull Request auto is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.