-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
37 lines (33 loc) · 1.17 KB
/
action.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
name: 'Ollama GitHub Code Reviewer'
description: 'Perform code review using Ollama API'
inputs:
model:
description: 'Ollama model to use for code review'
required: true
default: 'mistral'
runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Install Ollama
run: |
curl -fsSL https://ollama.com/install.sh | sh
ollama pull ${{ inputs.model }}
shell: bash
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v43
- name: Review code
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
review=$(curl -s http://127.0.0.1:11434/api/generate -d '{"model": "${{ inputs.model }}", "prompt": "Review the following file:\n\n```\n$(cat $file)\n```", "stream": false}' | jq -r '.response')
comment="Ollama Code Review for \`$file\`:\n\n$review"
echo "$comment" >> ollama_review.txt
done
gh pr comment ${{ github.event.pull_request.number }} --body "$(cat ollama_review.txt)"
shell: bash