-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (36 loc) · 1.25 KB
/
on_pr_review__gpt.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
name: "0. [on_review] Code Review GPT"
on:
pull_request_review_comment:
permissions:
contents: read
pull-requests: write
jobs:
run_code_review:
runs-on: ubuntu-latest
if: ${{ contains('\gpt,/gpt', github.event.comment.body) }}
steps:
- name: Check if allowed user and command
id: check_if_run
run: |
# Split allowed users into an array and check for exact match
IFS=',' read -ra allowed_users <<< "${{ secrets.GPT_ALLOWED_USERS }}"
current_user="${{ github.event.comment.user.login }}"
# Iterate over the allowed users array to check for an exact match
for user in "${allowed_users[@]}"; do
if [[ "$user" == "$current_user" ]]; then
echo "run_code_review=true" >> $GITHUB_ENV
exit 0
fi
done
echo "run_code_review=false" >> $GITHUB_ENV
- uses: actions/checkout@v3
if: env.run_code_review == 'true'
with:
fetch-depth: 0
- name: Code Review GPT
if: env.run_code_review == 'true'
uses: mattzcarey/[email protected]
with:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
MODEL: 'gpt-4o'
GITHUB_TOKEN: ${{ github.token }}