generated from remarkablemark/github-actions-composite-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
46 lines (41 loc) · 1.23 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
38
39
40
41
42
43
44
45
46
name: pull-request-review
description: Review pull request code with AI
author: remarkablemark
inputs:
model:
description: Language model name
default: codellama
required: false
prompt:
description: Input prompt before the PR diff
default: 'Code review the diff:'
required: false
comment-header:
description: Comment title in Markdown
default: '# Pull Request Review'
required: false
token:
description: GitHub token
required: false
runs:
using: composite
steps:
- name: Setup ollama
uses: ai-action/setup-ollama@v1
- name: Checkout repository
uses: actions/checkout@v4
- name: Comment code review
shell: bash
run: |
PROMPT_PREFIX=${{ toJSON(inputs.prompt) }}
PROMPT=$(printf '%s\n%s' "$PROMPT_PREFIX" $(gh pr diff $PR_NUMBER))
CODE_REVIEW=$(ollama run ${{ toJSON(inputs.model) }} "$PROMPT")
COMMENT_HEADER=${{ toJSON(inputs.comment-header) }}
COMMENT=$(printf '%s\n%s' "$COMMENT_HEADER" "$CODE_REVIEW")
gh pr comment $PR_NUMBER --body "$COMMENT"
env:
GITHUB_TOKEN: ${{ inputs.token || github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
branding:
icon: code
color: gray-dark