0.0.9 #9
This file contains hidden or 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
| # https://remarkablemark.org/blog/2025/02/23/run-ollama-large-language-models-on-github-actions/ | |
| name: Code Review | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| code-review: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Restore cached Ollama models to speed up CI runs | |
| - name: Restore Ollama model cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ollama/models | |
| key: ${{ runner.os }}-codellama-model | |
| restore-keys: | | |
| ${{ runner.os }}-codellama- | |
| # Install ollama | |
| - name: Setup ollama | |
| uses: ai-action/setup-ollama@v1 | |
| # Pull the codellama model if it hasn't been cached yet | |
| - name: Download codellama model | |
| run: ollama pull codellama | |
| # Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Run code review and comment on PR | |
| - name: Code review comment | |
| run: | | |
| PROMPT='Here is the code, find all the problems and flaws in it, pay attention to both stylistic flaws and vulnerabilities:' | |
| RESPONSE=$(ollama run codellama "$PROMPT\n$(gh pr diff $PR_NUMBER)") | |
| gh pr comment $PR_NUMBER --body "$RESPONSE" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} |