File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ jobs:
12
12
- name : Checkout code
13
13
uses : actions/checkout@v3
14
14
with :
15
- fetch-depth : 0
15
+ fetch-depth : 0 # seems necessary to diff with master instead of using HEAD
16
16
17
17
- name : Set up Python
18
18
uses : actions/setup-python@v4
19
19
with :
20
- python-version : ' 3.9' # Or your preferred version
20
+ python-version : ' 3.9'
21
21
22
22
- name : Install dependencies
23
23
run : |
@@ -28,20 +28,22 @@ jobs:
28
28
id : get_diff
29
29
run : |
30
30
echo "DIFF<<EOF" >> $GITHUB_OUTPUT
31
- git diff origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF} >> $GITHUB_OUTPUT
31
+ echo $( git diff origin/${GITHUB_BASE_REF}...origin/${GITHUB_HEAD_REF} | base64) >> $GITHUB_OUTPUT
32
32
echo "EOF" >> $GITHUB_OUTPUT
33
33
34
34
- name : Gemini API Call
35
35
id : gemini_review_call
36
36
run : |
37
37
python <<EOF
38
- import os
38
+ import os, base64
39
39
import google.generativeai as genai
40
40
41
41
genai.configure(api_key=os.environ['GEMINI_API_KEY'])
42
42
43
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 }}"
44
+ diff_encoded = "${{ steps.get_diff.outputs.DIFF }}".strip()
45
+ diff = base64.b64decode(diff_encoded).decode('utf-8')
46
+ prompt = f"Review this code diff for potential issues and provide feedback:\n\n {diff}"
45
47
response = model.generate_content(prompt)
46
48
47
49
print(f"REVIEW<<EOF")
You can’t perform that action at this time.
0 commit comments