File tree 1 file changed +57
-0
lines changed
1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Gemini PR Review
2
+
3
+ on :
4
+ pull_request :
5
+ types : [opened, synchronize] # Triggers on PR open and code updates
6
+
7
+ jobs :
8
+ gemini_review :
9
+ runs-on : ubuntu-latest
10
+
11
+ steps :
12
+ - name : Checkout code
13
+ uses : actions/checkout@v3
14
+ with :
15
+ fetch-depth : 0
16
+
17
+ - name : Set up Python
18
+ uses : actions/setup-python@v4
19
+ with :
20
+ python-version : ' 3.9' # Or your preferred version
21
+
22
+ - name : Install dependencies
23
+ run : |
24
+ python -m pip install --upgrade pip
25
+ pip install google-generativeai
26
+
27
+ - name : Get PR diff
28
+ id : get_diff
29
+ run : |
30
+ echo "DIFF<<EOF" >> $GITHUB_OUTPUT
31
+ git diff origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF} >> $GITHUB_OUTPUT
32
+ echo "EOF" >> $GITHUB_OUTPUT
33
+
34
+ - name : Gemini API Call
35
+ id : gemini_review_call
36
+ run : |
37
+ python <<EOF
38
+ import os
39
+ import google.generativeai as genai
40
+
41
+ genai.configure(api_key=os.environ['GEMINI_API_KEY'])
42
+
43
+ model = genai.GenerativeModel('gemini-pro')
44
+ prompt = f"Review this code diff for potential issues and provide feedback:\n\n ${{ steps.get_diff.outputs.DIFF }}"
45
+ response = model.generate_content(prompt)
46
+
47
+ print(f"REVIEW<<EOF")
48
+ print(response.text)
49
+ print(f"EOF")
50
+ EOF
51
+ env :
52
+ GEMINI_API_KEY : ${{ secrets.GEMINI_API_KEY }}
53
+
54
+ - name : Post Review Comment (Placeholder)
55
+ run : |
56
+ echo "This is a placeholder for posting a review comment."
57
+ echo "Gemini Review: ${{ steps.gemini_review_call.outputs.REVIEW }}"
You can’t perform that action at this time.
0 commit comments