Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action.md with alternative bot trigger #340

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions action.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ First thing you'd need to do is create an OPENAI_API_KEY secret in github, more

Once you've set your secret you can create a new file in your workflow called crgpt.yml, which should look like something seen below. An important attribute to include, is the fetch-depth of the checkout action below. Currently the action only works when it has access to the repo's entire commit history.

```shell
### Workflow yml option 1: Review every PR

Trigger a code review on any PR into main, updating it each time you push changes.

```yaml
name: Code Review GPT

on:
Expand All @@ -27,4 +31,36 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: 'gpt-4o'
GITHUB_TOKEN: ${{ github.token }}
```
```

### Workflow yml option 2: Add a code review bot

In this config, a GPT CR is triggered when a specific user is added as a "reviewer" in the Github UI. Create an additional Github account such as 'YourProject-ML-CR-bot', then specify the account username in the config.

This option can save on API costs by only reviewing when explicity asked to. It can also be used to avoid reviewing PRs before they are ready (draft/WIP PRs).

To trigger a re-review, simply remove and re-add the bot to the reviewers list.

```yaml
name: Code Review GPT

on:
pull_request:
types: [ review_requested ]

jobs:
run_code_review:
mattzcarey marked this conversation as resolved.
Show resolved Hide resolved
if: ${{ github.event.requested_reviewer.login == 'YourProject-ML-CR-bot'}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Code Review GPT
uses: mattzcarey/[email protected]
with:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: 'gpt-4o'
GITHUB_TOKEN: ${{ github.token }}
```
Loading