Skip to content

Commit dee936e

Browse files
author
Jakub Jirous
committed
[github] code review using open api
1 parent 1dbf491 commit dee936e

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

.github/workflows/code_review.yml

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
1-
name: "Code Review"
1+
name: "Code Review Workflow"
22

33
on:
44
pull_request:
5-
types: [opened, edited, synchronize]
6-
7-
env:
8-
API_KEY: ${{ secrets.OPENAI_API_KEY }}
5+
branches:
6+
- main
7+
- develop
98

109
jobs:
11-
review:
10+
build:
1211
runs-on: ubuntu-latest
1312

1413
steps:
1514
- name: "Checkout code"
1615
uses: actions/checkout@v2
1716

18-
- name: Call ChatGPT API
19-
id: call_api
17+
- name: "Install dependencies"
2018
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) }}"}')
19+
npm ci
2220
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;
21+
- name: "Run TypeScript build"
22+
run: |
23+
npm run build
3424
35-
const octokit = new github.GitHub(process.env.GITHUB_TOKEN);
25+
- name: "Run TypeScript lint"
26+
run: |
27+
npm run lint
3628
37-
octokit.issues.createComment({
38-
owner,
39-
repo,
40-
issue_number,
41-
body: feedback
42-
});
29+
- name: "ChatGPT API Code Review"
30+
id: chatgpt_api
31+
uses: openai/actions/chatgpt_api@main
32+
with:
33+
text: |
34+
Please review the code for the edabit-code-challenge project and provide feedback on best practices, security concerns, and any other recommendations for improvement. The project is written in TypeScript and uses Jest for testing. The code is located in the ${{ github.workspace }} directory.
35+
prompt: |
36+
edabit-code-challenge code review
37+
max_tokens: 300
38+
model: davinci
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sonarcloud.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ name: "SonarCloud"
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches:
6+
- main
67

78
pull_request:
8-
branches: ["main"]
9+
branches:
10+
- main
911

1012
workflow_dispatch:
1113

0 commit comments

Comments
 (0)