-
-
Notifications
You must be signed in to change notification settings - Fork 2
125 lines (119 loc) · 4.74 KB
/
chatgpt-review.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# kics-scan disable=555ab8f9-2001-455e-a077-f2d0f41e2fb9
---
name: Code Review
on:
pull_request:
types:
- ready_for_review
- synchronize
issue_comment:
types:
- created
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
# 1) issue_commentイベントの場合、PRのSHAを取得する
- name: Retrieve PR HEAD SHA (for issue_comment only)
if: ${{ github.event_name == 'issue_comment' }}
id: pr-info
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script:
|
// コメントされたIssueがPull Requestであることを前提
const prNumber = context.payload.issue.number;
// PR情報を取得
const { data: pr } = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
// HEADのSHAを出力
core.setOutput("sha", pr.head.sha);
# 2) チェックアウト (コメントのときは上ステップから取得したSHA, PRイベントならPull RequestのSHA)
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ steps.pr-info.outputs.sha || github.event.pull_request.head.sha }}
# 3) 現在のコミットがマージコミットかを判定
- name: Check if current commit is a merge commit
id: check_merge
run:
|
# 実際にチェックアウトしているコミットSHAを確認
CURRENT_SHA="${{ steps.pr-info.outputs.sha || github.event.pull_request.head.sha }}"
PARENTS_COUNT=$(git rev-list --parents -n 1 "${CURRENT_SHA}" | wc -w)
# 親が1つであれば (コミットID + 親1つ) = 2単語
# 親が2つなら (コミットID + 親2つ) = 3単語 以上となるので、
# 3以上ならマージコミットとみなす
if [ "${PARENTS_COUNT}" -ge 3 ]; then
echo "is_merge=true" >> "${GITHUB_OUTPUT}"
else
echo "is_merge=false" >> "${GITHUB_OUTPUT}"
fi
# 4) マージコミットならスキップ
- name: Skip on merge commit
if: steps.check_merge.outputs.is_merge == 'true'
run:
|
echo "This is a merge commit. Skipping this job."
exit 0
# 5) ChatGPTを用いた自動コードレビュー
- uses: anc95/ChatGPT-CodeReview@main
# 以下のいずれかを満たすときに実行:
# 1) issue_comment で /review が含まれる
# 2) pull_request.ready_for_review (ドラフト解除)
# 3) pull_request.synchronize (新コミット) かつ "プリーズレビュー" ラベルがある
if:
>
(
github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '/review')
)
OR
(
github.event_name == 'pull_request' &&
(
github.event.action == 'ready_for_review'
OR
(
github.event.action == 'synchronize' &&
contains(github.event.pull_request.labels.*.name, 'プリーズレビュー')
)
)
)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LANGUAGE: Japanese
OPENAI_API_ENDPOINT: https://api.openai.com/v1
MODEL: o1-mini
PROMPT:
>
Request: perform PR review mcfuntion code for Minecraft 1.21.1
Role: Respond as code reviewer for Minecraft distribution world “The Unusual SkyBlock”.
Regulation: keep brief to point, 50-300 words or less, Markdown format.
Rule:
. Avoid halcyonation provide reliable information.
. do not copy answers, use original content.
. review code in Minecraft 1.21.1
Review Refine:
. check quality readability code
. Evaluate impact proposed changes on existing functionality
. identify performance concerns
. identify potential impact on gameplay aware of changes affect gameplay
Reference:
- Repository: [The Unusual SkyBlock](https://github.com/TUSB/TheUnusualSkyBlock)
- Documentation:
- [GitHub Wiki](https://github.com/TUSB/TheUnusualSkyBlock/wiki/Top)
- [Seesaawiki](https://seesaawiki.jp/theunusualskyblock/)
Run Scenario: respond as code reviewer.
top_p: 1
temperature: 1
MAX_PATCH_LENGTH: 10000
IGNORE_PATTERNS: ./*,*.md