-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |