generated from BlossomLabs/web3-turbo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
49 lines (49 loc) · 2.02 KB
/
ai-code-review.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: "Code Review by Gemini AI"
on:
pull_request:
paths:
- "**/*.ts"
- "**/*.tsx"
- "**/*.sol"
jobs:
review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: "Get filtered diff of the pull request"
id: get_diff
shell: bash
env:
PULL_REQUEST_HEAD_REF: "${{ github.event.pull_request.head.ref }}"
PULL_REQUEST_BASE_REF: "${{ github.event.pull_request.base.ref }}"
run: |-
git fetch origin "${{ env.PULL_REQUEST_HEAD_REF }}" # fetch the branch with changes
git fetch origin "${{ env.PULL_REQUEST_BASE_REF }}" # fetch the target branch
git checkout "${{ env.PULL_REQUEST_HEAD_REF }}" # switch to the branch with changes
git diff -- '*.ts' '*.tsx' '*.sol' "origin/${{ env.PULL_REQUEST_BASE_REF }}" > "filtered_diff.txt" # generate a filtered diff
{
echo "pull_request_diff<<EOF";
cat "filtered_diff.txt";
echo 'EOF';
} >> $GITHUB_OUTPUT # save the filtered diff to an output variable
- uses: rubensflinco/[email protected]
name: "Code Review by Gemini AI"
continue-on-error: true
id: review
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repository: ${{ github.repository }}
github_pull_request_number: ${{ github.event.pull_request.number }}
git_commit_hash: ${{ github.event.pull_request.head.sha }}
model: "gemini-1.5-pro-latest"
pull_request_diff: |-
${{ steps.get_diff.outputs.pull_request_diff }}
pull_request_chunk_size: "5000" # chunk size is important to avoid exceeding the API limits
extra_prompt: |-
Only focus on logic and security-sensitive sections of the code.
Skip reviewing helper functions, comments, or tests.
log_level: "DEBUG"