Skip to content

Commit

Permalink
feat: add code reviews by cody
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddigital committed Sep 29, 2024
1 parent 76e887b commit f8ffca8
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/code_review.yml/code_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Code Review

permissions:
contents: read
pull-requests: write

on:
pull_request:
pull_request_review_comment:
types: [created]

concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}-${{ github.event_name == 'pull_request_review_comment' && 'pr_comment' || 'pr' }}
cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}

jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Cody AI Code Review Tool
uses: codylabs/cody-code-reviewer@master
with:
pr_number: ${{ github.event.pull_request.number }}
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
55 changes: 54 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,58 @@
## About

With no coding required to set up, Cody will automatically summarize and code review your changes on every pull request or merge request using AI.

Read more at [https://codylabs.io/](https://codylabs.io/)

## Installation

Installation is as simple as adding your open API key, and creating a Github Actions workflow file to your repo.

If you prefer you can watch these steps on YouTube:

1. Add OPENAI_API_KEY as a github repo secret via Settings > Actions > Secrets and variables > New reposity secret. The variable name should be OPENAI_API_KEY and the value should be your Open API API Key.

![alt text](add_a_secret_image.png)

Note that GITHUB_TOKEN does not need to be added as is available by default.

2. Add the following to a new folder in your repo .github/workflows/code_review.yml

```
name: Code Review by Cody
permissions:
contents: read
pull-requests: write
on:
pull_request:
pull_request_review_comment:
types: [created]
concurrency:
group: ${{ github.repository }}-${{ github.event.number || github.head_ref || github.sha }}-${{ github.workflow }}-${{ github.event_name == 'pull_request_review_comment' && 'pr_comment' || 'pr' }}
cancel-in-progress: ${{ github.event_name != 'pull_request_review_comment' }}
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Cody AI Code Review Tool
uses: codylabs/cody-code-reviewer@master
with:
pr_number: ${{ github.event.pull_request.number }}
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
```

3. Commit your code and watch Cody in action!

## Development

Clone the repo.
Expand All @@ -20,9 +71,11 @@ To deactivate, `deactivate`

Create an .env

`OPENAI_API_KEY=token_here
```
OPENAI_API_KEY=token_here
GITHUB_TOKEN=token_here
GITLAB_TOKEN=your_gitlab_token_here
```

And then run

Expand Down
Binary file added add_a_secret_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f8ffca8

Please sign in to comment.