-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
68 lines (61 loc) · 1.81 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
---
name: 'OpenAI: Generate Pull Request Title and Description'
description: 'Generate Pull Request Title and Description using OpenAI API'
author: Takeru O'oyama @tqer39
branding:
color: 'green'
icon: 'code'
inputs:
commit-log-history-limit:
description: 'Commit log history limit'
required: true
default: '70'
github-token:
description: 'GitHub token'
required: true
default: ""
openai-api-key:
description: 'OpenAI API key'
required: true
default: ""
# see https://platform.openai.com/docs/models#continuous-model-upgrades
openai-model:
description: 'OpenAI Model'
required: true
default: 'gpt-3.5-turbo'
runs:
using: 'composite'
steps:
- name: Setup Python
uses: actions/setup-python@v5
- name: pip upgrade
run: python -m pip install --upgrade pip
shell: bash
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "0.4.26"
- name: Setup uv
run: |
uv venv
source .venv/bin/activate
uv sync --no-dev --directory ${{ github.action_path }}
shell: bash
- name: Generate PR Title and Description
env:
COMMIT_LOG_HISTORY_LIMIT: ${{ inputs.commit-log-history-limit }}
OPENAI_API_KEY: ${{ inputs.openai-api-key }}
OPENAI_MODEL: ${{ inputs.openai-model }}
run: |
uv run ${{ github.action_path }}/scripts/generate_pr_description.py > pr_output.txt
cat pr_output.txt
shell: bash
- name: Update PR Title and Description
env:
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PR_TITLE=$(head -n 1 pr_output.txt)
PR_BODY=$(tail -n +2 pr_output.txt)
gh pr edit $PR_NUMBER --title "$PR_TITLE" --body "$PR_BODY"
shell: bash