File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : " Code Review"
2
+
3
+ on :
4
+ pull_request :
5
+ types : [opened, edited, synchronize]
6
+
7
+ env :
8
+ API_KEY : ${{ secrets.OPENAI_API_KEY }}
9
+
10
+ jobs :
11
+ review :
12
+ runs-on : ubuntu-latest
13
+
14
+ steps :
15
+ - name : " Checkout code"
16
+ uses : actions/checkout@v2
17
+
18
+ - name : Call ChatGPT API
19
+ id : call_api
20
+ run : |
21
+ code_review_feedback=$(curl -X POST -H "Authorization: Bearer $API_KEY" -d '{"model": "text-davinci-002", "prompt": "Code Review Feedback: ${{ toJson(github.event.pull_request.head.repo.html_url) }}"}')
22
+
23
+ - name : " Add comment to pull request"
24
+ uses : actions/github-script@v3
25
+ env :
26
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
27
+ with :
28
+ script : |
29
+ const response = JSON.parse(process.env.code_review_feedback);
30
+ const feedback = response.choices[0].text;
31
+ const issue_number = context.payload.pull_request.number;
32
+ const repo = context.payload.repository.name;
33
+ const owner = context.payload.repository.owner.login;
34
+
35
+ const octokit = new github.GitHub(process.env.GITHUB_TOKEN);
36
+
37
+ octokit.issues.createComment({
38
+ owner,
39
+ repo,
40
+ issue_number,
41
+ body: feedback
42
+ });
You can’t perform that action at this time.
0 commit comments