-
Notifications
You must be signed in to change notification settings - Fork 31
78 lines (65 loc) · 2.61 KB
/
ai-commit-review.yml
File metadata and controls
78 lines (65 loc) · 2.61 KB
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
name: "[AI] Commit review"
on:
workflow_dispatch:
push:
branches:
- main
run-name: "Commit: ${{ github.event.head_commit.message }}"
jobs:
analyze_last_commit:
permissions:
contents: read
models: read
runs-on: ubuntu-latest
env:
LAST_COMMIT: 'n/a'
DIFF_DATA: ''
steps:
- name: Checkout repository (main branch and 2 last commits)
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Get diff from last commit
run: |
LAST_COMMIT=$(git rev-parse --short HEAD)
echo "LAST_COMMIT=$LAST_COMMIT" >> $GITHUB_ENV
DIFF=$(git diff HEAD^ HEAD)
printf "DIFF_DATA<<EOF\n%s\nEOF\n" "$DIFF" >> $GITHUB_ENV
- name: Send message to Telegram
uses: appleboy/telegram-action@master
with:
token: ${{ secrets.TELEGRAM_API_TOKEN }}
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
debug: true
format: markdown
message: |
🔔 **Action**: commit [${{ env.LAST_COMMIT }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
📁 **Repository**: ${{ github.repository }}
👤 **User**: ${{ github.actor }}
💬 **Message**: ${{ github.event.head_commit.message }}
- name: Generate report using AI
id: ai_query
uses: actions/ai-inference@v2
with:
model: gpt-4.1
max-tokens: 2048
system-prompt: |
You are a technical writer (commit reviewer) in Russian.
Analyze the provided git diff of the latest commit.
Based on this analysis, provide a brief description of the changes and detailed suggestions for improvement or refinement.
The message must contain two sections: "💡 Обзор изменений" and "💁♂️ Рекомендации по улучшению" without heading symbols.
The response must be strictly in Markdown format and adhere to the 3500 character limit for sending messages in Telegram.
prompt: |
Analyze the following code changes in commit ${{ env.LAST_COMMIT }}:
${{ env.DIFF_DATA }}
- name: Send AI report to Telegram
uses: appleboy/telegram-action@master
continue-on-error: true
with:
token: ${{ secrets.TELEGRAM_API_TOKEN }}
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
debug: true
format: markdown
message: |
🔔 Report for ${{ env.LAST_COMMIT }} commit from AI
${{ steps.ai_query.outputs.response }}