Skip to content

bbunhere/web-roadtodevfest-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Pull Request with Gemini API

WTM Latest Stable Version License

Quick Start

1. Create package.json

{
    "name": "project_name",
    "main": "index.html",
    "devDependencies": {
        "@types/node": "^22.9.0"
    },
    "dependencies": {}
}

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

3. Create .github/workflows/[gemini-review-code].yml

name: "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: Install dependencies
        run: npm install

      - 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: ./
        env: # Set environment variables here
          GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
          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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • SCSS 40.7%
  • HTML 31.4%
  • JavaScript 22.5%
  • CSS 5.4%