code-butler
works with GitHub Actions.
Please refer to the following example to set up .github/workflows/code-butler.yml
.
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: en
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
lang: ja
- GITHUB_TOKEN
- This should already be available to the GitHub Action environment. This is used to add comments to the pull request.
- OPENAI_API_KEY
- use this to authenticate with OpenAI API. You can get one here. Please add this key to your GitHub Action secrets.
- cmd
- This is the command to run. Currently,
review
andchat
are supported. review
will add a comment to the pull request with a code review.chat
will add a comment to the pull request with a chat message.
- This is the command to run. Currently,
- model
- This is the model to use. default is
gpt-3.5-turbo
.
- This is the model to use. default is
- comment_body
- This is the body of the comment that will be added to the pull request. This is only used when
cmd
is set tochat
. - This is an optional parameter. The body of the comment that triggered the GitHub Action will be used.
- This is the body of the comment that will be added to the pull request. This is only used when
- lang
- This is the language to use. default is
en
. - Currently,
en
andja
are supported.
- This is the language to use. default is
- exclude_files
- This is the file to exclude from the code review. default is
""
. - This is an optional parameter. You can specify the file you want to exclude from the code review.
- The format is
foo/var/test.ts
orfoo/bar/test.ts,foo/bar/test.yml
. - The file path is relative to the repository root.
- The file path is separated by
,
. - If only a directory is specified, files containing that directory are also excluded.
- This is the file to exclude from the code review. default is
- exclude_extensions
- This is the extension to exclude from the code review. default is
""
. - This is an optional parameter. You can specify the extension you want to exclude from the code review.
- The format is
ts
orts,yml
. - The extension is separated by
,
.
- This is the extension to exclude from the code review. default is
When you comment /review
within a pull request, the AI will perform a code review for you.
The PR Analysis section will describe the main theme, a summary of the PR, and what type of PR it is.
The PR Feedback section provides suggestions and constructive feedback on the code.
The Security concerns section will also point out any security concerns you may have.
When the gpt-4-1106-preview
model is selected, the entire diff is sent to OpenAI without grouping.
This is different from the default behavior, where the diff is grouped before being sent to OpenAI.
This feature allows for more detailed and specific code reviews when using the gpt-4-1106-preview
model.
When you comment /chat
within a pull request, the AI will respond to your comment.
Basically any question can be answered.
You will be able to communicate with ChatGPT on PR as well.
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: ja
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
lang: ja
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: en
model: gpt-4-1106-preview
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
model: gpt4-1106-preview
lang: en
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: en
exclude_files: "foo/bar/test.ts,foo/bar/test.yml"
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
lang: en
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: en
exclude_files: "foo/bar/"
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
lang: en
name: Code Butler
permissions:
contents: read
pull-requests: write
on:
issue_comment:
types: [created]
jobs:
review:
if: startsWith(github.event.comment.body, '/review')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: review
lang: en
exclude_extensions: "ts,yml"
chat:
if: startsWith(github.event.comment.body, '/chat')
runs-on: ubuntu-latest
steps:
- uses: ca-dp/code-butler@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
cmd: chat
comment_body: ${{ github.event.comment.body }}
lang: en
This project is licensed under the MIT License.
see the LICENSE file for details.