-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
78 lines (67 loc) · 2.7 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: 'AutoCoder'
description: 'This action automates the process of generating code from GitHub issues using OpenAIs ChatGPT and subsequently creates a pull request with the generated code for review.'
author: 'github.com/PGSch'
inputs:
GITHUB_TOKEN:
description: 'Personal access token (PAT) used for GitHub API authentication. This token is required to create pull requests and handle other repository interactions.'
required: true
REPOSITORY:
description: 'The repository where the action will be executed.'
required: true
ISSUE_NUMBER:
description: 'The number of the issue that triggered the action.'
required: true
OPENAI_API_KEY:
description: 'API key for OpenAI, enabling interactions with the ChatGPT service to generate code based on issue descriptions.'
required: true
SCRIPT_PATH:
description: 'The path to the script that interacts with ChatGPT and generates code.'
required: false
default: scripts/script.sh
outputs:
pull_request_url:
description: 'The URL of the pull request that has been automatically created, containing the auto-generated code for review and potential merging.'
runs:
using: 'composite'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Configure Git
run: |
git config --local user.name "autocoder-bot"
git config --local user.email "[email protected]"
shell: bash
- name: make the script executable
run: chmod +x ${{ github.action_path }}/${{ inputs.SCRIPT_PATH }}
shell: bash
- name: Generate Code with ChatGPT
id: generate_code
run: ${{ github.action_path }}/${{ inputs.SCRIPT_PATH }} ${{ inputs.GITHUB_TOKEN }} ${{ inputs.REPOSITORY }} ${{ inputs.ISSUE_NUMBER }} ${{ inputs.OPENAI_API_KEY }}
shell: bash
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: autocoder-artifact
path: autocoder-bot/
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: autocoder-artifact
path: autocoder-bot/
- name: List Files
run: ls -R ./autocoder-bot
shell: bash
- name: Commit Changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "autocoder-bot"
git add autocoder-bot
git commit -m "Add generated code from ChatGPT for issue #${{ inputs.ISSUE_NUMBER }}"
shell: bash
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
labels: "autocoder-bot"
author: autocoder-bot <[email protected]>
title: "PR to issue #${{ inputs.ISSUE_NUMBER }}"
branch: autocoder-branch-${{ inputs.ISSUE_NUMBER }}