-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
59 lines (54 loc) · 1.79 KB
/
Copy pathaction.yml
File metadata and controls
59 lines (54 loc) · 1.79 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
name: 'Analyze Pull Request with OpenAI'
description: 'This action automates the process of reviewing code from GitHub pull-requests using OpenAI API.'
author: 'ProductDock'
branding:
icon: git-pull-request
color: blue
inputs:
OPENAI_API_KEY:
description: 'OpenAI API key'
required: true
GITHUB_TOKEN:
description: 'GitHub token'
required: true
REPOSITORY:
description: 'GitHub repository'
required: true
PR_NUMBER:
description: 'Pull request number'
required: true
GPT_MODEL:
description: 'GPT model to use'
required: false
default: 'gpt-4o-mini'
MAX_TOKENS:
description: 'Maximum tokens to generate'
required: false
default: '500'
runs:
using: 'composite'
steps:
- name: Create temp directory
run: mkdir -p ${{ github.action_path }}/tmp
shell: bash
- name: Extract PR diff
run: |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} > ${{ github.action_path }}/tmp/pr_diff.txt
echo "DIFF_FILE_PATH=${{ github.action_path }}/tmp/pr_diff.txt" >> $GITHUB_ENV
shell: bash
- name: Make script executable
run: chmod +x ${{ github.action_path }}/scripts/analyze-code.sh
shell: bash
- name: Analyze code with OpenAI
env:
OPENAI_API_KEY: ${{ inputs.OPENAI_API_KEY }}
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
REPOSITORY: ${{ inputs.REPOSITORY }}
PR_NUMBER: ${{ inputs.PR_NUMBER }}
DIFF_FILE_PATH: ${{ env.DIFF_FILE_PATH }}
GPT_MODEL: ${{ inputs.GPT_MODEL }}
MAX_TOKENS: ${{ inputs.MAX_TOKENS }}
run: ${{ github.action_path }}/scripts/analyze-code.sh \
$OPENAI_API_KEY $GITHUB_TOKEN $REPOSITORY $PR_NUMBER \
$DIFF_FILE_PATH $GPT_MODEL $MAX_TOKENS
shell: bash