Skip to content

Commit

Permalink
Create action.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
brobles82 authored Mar 18, 2024
1 parent 8d2cb09 commit fdf85b4
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions action.yml
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

0 comments on commit fdf85b4

Please sign in to comment.