Git Product home page Git Product logo

chatgpt-pr-review's Introduction

ChatGPT Pull Request Review Action

Introduction

This GitHub action autonomously reviews pull requests by supplying the contents of changed files (introduced via a simple prompt) to ChatGPT.

Usage

ChatGPT integration

The action integrates with OpenAI's v2 ChatGPT API, and thus requires access to a valid API key with which to authenticate requests to OpenAI platforms. Sign up and generate your own key here (once logged in, navigate to Personal > View API keys). The most secure way to expose your key to the action is via GitHub secrets.

GitHub integration

The action submits reviews to a pull request via the GitHub REST API. The easiest way to authenticate the action to the GitHub API is to make use of the token that GitHub generates at the start of each workflow run. Beware that this token is, by default, only granted read permissions for the target repository - you will need to grant the token write permissions.

Files

The action targets all new or modified files for review, you can (and probably should) limit the scope of the review by providing a comma separated list of Unix file patterns to the file action input. For example:

  • "*.java" targets all Java files
  • "*.py,src/*" targets all Python files and all files in the src directory

Workflow configuration

An example configuration, note:

  • the action is designed to review pull requests, as such the workflow should be triggered on pull_request
  • the OpenAI API key is provided as a GitHub secret, you may need to adjust this configuration to extract the secret you created above
  • the action makes use of the default GitHub token (as discussed above), this token is exposed as a GitHub secret secrets.GITHUB_TOKEN
  • The default run of this action will trigger a check list based review but if you wish to change the review type you can do so by setting the secret variable secrets.REVIEW_TYPE and can set it to scalability
name: pr-review
on:
  pull_request:
    types: [opened, synchronize]
jobs:
  review:
    name: ChatGPT code review
    runs-on: ubuntu-latest
    steps:
      - uses: agogear/[email protected]
        with:
          openai_api_key: ${{ secrets.OPENAI_API_KEY }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
          github_pr_id: ${{ github.event.number }}
          review_type: ${{ secrets.REVIEW_TYPE }}

chatgpt-pr-review's People

Contributors

maxplumley avatar abrarhayat avatar agogear avatar simonjiang97 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.