Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

OpenAI ChatGPT Code Review

v0.2.2

OpenAI ChatGPT Code Review

play

OpenAI ChatGPT Code Review

A GitHub Action that uses OpenAI ChatGPT to review code in pull request

Installation

Copy and paste the following snippet into your .yml file.

              

- name: OpenAI ChatGPT Code Review

uses: adshao/[email protected]

Learn more about this action in adshao/chatgpt-code-review-action

Choose a version

Simplify code reviews, just say chatgpt!

OpenAI ChatGPT Code Review

A GitHub Action that uses OpenAI ChatGPT to analyze code in pull request review comments.

Usage

To use this action in your workflow, add the following step:

name: OpenAI ChatGPT Code Review
uses: adshao/[email protected]
with:
    LANGUAGE: 'English'
    PROGRAMMING_LANGUAGE: 'JavaScript'
    OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
    GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
    FULL_REVIEW_COMMENT: 'chatgpt'
    REVIEW_COMMENT_PREFIX: 'chatgpt:'

Inputs

This action accepts the following inputs:

  • LANGUAGE (optional): The response language of the OpenAI ChatGPT API. Default is "en".
  • PROGRAMMING_LANGUAGE (optional): The programming language of the code in the GitHub repository. If not provided, the detected programming language will be used.
  • OPENAI_TOKEN (required): The API token for the OpenAI ChatGPT API.
  • GITHUB_TOKEN (required): The API token for the Github API.
  • FULL_REVIEW_COMMENT (required): The comment to trigger code review for the pull request.
  • REVIEW_COMMENT_PREFIX (required): The comment prefix to trigger code review with the comment content.

Outputs

This action does not produce any outputs.

Example workflow

Here's an example workflow that uses this action to analyze code in pull request review comments:

name: Code Review

on:
  issue_comment:
    types: [created, edited]

jobs:
  code-review:
    runs-on: ubuntu-latest
    if: github.event.comment.user.login == 'adshao' && startsWith(github.event.comment.body, 'chatgpt')
    steps:
    - name: OpenAI ChatGPT Code Review
      uses: adshao/chatgpt-code-review-action@main
      with:
        LANGUAGE: 'English'
        PROGRAMMING_LANGUAGE: 'JavaScript'
        OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }}
        GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
        FULL_REVIEW_COMMENT: 'chatgpt'
        REVIEW_COMMENT_PREFIX: 'chatgpt:'

This workflow runs the OpenAI ChatGPT Code Review action when a pull request comment is created or edited. The action uses the LANGUAGE, PROGRAMMING_LANGUAGE, FULL_REVIEW_COMMENT, REVIEW_COMMENT_PREFIX, OPENAI_TOKEN and GITHUB_TOKEN input values to analyze the code in the pull request comment.

  • If the comment starts with chatgpt: and is sent by adshao, the workflow will be triggered.

  • If the comment is exactly chatgpt, it will trigger a code review for the diff of the pull request.

demo

More Examples

go-binance: adshao/go-binance#461 (comment)

License

The code in this repository is licensed under the MIT license. See LICENSE for more information.