Skip to content

Commit

Permalink
package actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pompurin404 committed Oct 23, 2024
1 parent f8e359e commit da56fe0
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Auto Close Issue

### Usage

```yaml
name: Auto Close Issue
on:
issues:
types: [opened]

jobs:
auto_close_issue:
runs-on: ubuntu-latest
steps:
- name: Auto Close Issue
uses: mihomo-party-org/auto-close-issue@main
with:
title: ${{ github.event.issue.title }}
body: ${{ github.event.issue.body }}
number: ${{ github.event.issue.number }}
token: ${{ secrets.GITHUB_TOKEN }}
url: 'https://api.openai.com'
key: 'sk-xxxxxx'
prompt: 'xxxxxx'
```
53 changes: 53 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Auto Close Issue"
branding:
icon: "check-circle"
color: "black"
description: "Review and automatically close issues through OpenAI"
inputs:
title:
description: "Issue title"
required: true
default: ${{ github.event.issue.title }}
body:
description: "Issue body"
required: true
default: ${{ github.event.issue.body }}
number:
description: "Issue number"
required: true
default: ${{ github.event.issue.number }}
token:
description: "GitHub token"
required: true
default: ${{ secrets.GITHUB_TOKEN }}
url:
description: "OpenAI API Base URL"
required: true
default: "https://api.openai.com"
key:
description: "OpenAI API Key"
required: true
prompt:
description: "OpenAI system prompt"
required: false
default: You are an AI assistant specialized in analyzing GitHub issues. Your task is to evaluate the title and body of a given issue and determine if they align with the selected options or checkboxes in the issue template, especially focusing on the "Verify steps" section. Finally give the evaluation result, whether the issue should be closed, whether the issue needs to be locked, and the reasons in Chinese. Consider all available information, not just the checkboxes. If there's not enough information to make a determination, state that in your response. If the content involves abusive or inappropriate language, please lock the issues

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
repository: mihomo-party-org/auto-close-isssues
- uses: actions/setup-go@v5
with:
go-version: "1.23"
- run: go run main.go
shell: bash
env:
ISSUE_TITLE: ${{ inputs.title }}
ISSUE_BODY: ${{ inputs.body }}
ISSUE_NUMBER: ${{ inputs.number }}
GITHUB_TOKEN: ${{ inputs.token }}
API_URL: ${{ inputs.url }}
API_KEY: ${{ inputs.key }}
SYSTEM_PROMPT: ${{ inputs.prompt }}
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
owner = "mihomo-party-org"
repo = "mihomo-party"
issue IssueInfo
prompt string
)

type IssueInfo struct {
Expand Down Expand Up @@ -57,7 +58,7 @@ func init() {
Body: os.Getenv("ISSUE_BODY"),
Number: issueNumber,
}

prompt = os.Getenv("SYSTEM_PROMPT")
}

func main() {
Expand Down Expand Up @@ -333,7 +334,7 @@ func chat(s string, m string) (string, error) {
client := NewOpenAIClient(os.Getenv("API_URL"), os.Getenv("API_KEY"))

messages := []ChatMessage{
{Role: "system", Content: `You are an AI assistant specialized in analyzing GitHub issues. Your task is to evaluate the title and body of a given issue and determine if they align with the selected options or checkboxes in the issue template, especially focusing on the "Verify steps" section. Finally give the evaluation result, whether the issue should be closed, whether the issue needs to be locked, and the reasons in Chinese. Consider all available information, not just the checkboxes. If there's not enough information to make a determination, state that in your response. If the content involves abusive or inappropriate language, please lock the issues`},
{Role: "system", Content: prompt},
{Role: "user", Content: s},
}

Expand Down

0 comments on commit da56fe0

Please sign in to comment.