Skip to content

Commit 21ea289

Browse files
committed
Add or update GitHub Actions workflows
1 parent a0ab605 commit 21ea289

File tree

1 file changed

+11
-52
lines changed

1 file changed

+11
-52
lines changed

.github/workflows/ai-responder.yml

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: AI Issue Responder
23

34
on:
@@ -13,58 +14,16 @@ jobs:
1314
runs-on: ubuntu-latest
1415

1516
steps:
16-
- name: Get issue content
17-
id: get_issue
18-
env:
19-
ISSUE_TITLE: ${{ github.event.issue.title }}
20-
ISSUE_BODY: ${{ github.event.issue.body }}
17+
- name: Download AI responder script
2118
run: |
22-
echo "title=$ISSUE_TITLE" >> "$GITHUB_OUTPUT"
23-
echo "body=$ISSUE_BODY" >> "$GITHUB_OUTPUT"
24-
25-
- name: Call OpenAI API
26-
id: ai
27-
env:
28-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
29-
ISSUE_TITLE: ${{ steps.get_issue.outputs.title }}
30-
ISSUE_BODY: ${{ steps.get_issue.outputs.body }}
31-
run: |
32-
prompt="You're a helpful AI assistant. "
33-
prompt+="Reply concisely to the following GitHub issue."
34-
35-
json=$(jq -n \
36-
--arg model "gpt-4o" \
37-
--arg system "$prompt" \
38-
--arg user "$ISSUE_TITLE - $ISSUE_BODY" \
39-
'{
40-
model: $model,
41-
messages: [
42-
{role: "system", content: $system},
43-
{role: "user", content: $user}
44-
],
45-
temperature: 0.5
46-
}')
19+
curl -sSL "https://raw.githubusercontent.com/dmzoneill/dmzoneill/main/ai-responder.py" -o ai-responder.py
20+
chmod +x ai-responder.py
4721
48-
api_url="https://api.openai.com/v1/chat/completions"
49-
auth="Authorization: Bearer $OPENAI_API_KEY"
50-
ctype="Content-Type: application/json"
51-
52-
response=$(curl -s "$api_url" \
53-
-H "$auth" \
54-
-H "$ctype" \
55-
-d "$json" | jq -r '.choices[0].message.content')
56-
57-
echo "reply=$response" >> "$GITHUB_OUTPUT"
58-
59-
- name: Reply to issue
22+
- name: Run AI responder
6023
env:
61-
COMMENT_BODY: ${{ steps.ai.outputs.reply }}
62-
run: |
63-
api_url="https://api.github.com/repos/${{ github.repository }}"
64-
api_url+="/issues/${{ github.event.issue.number }}/comments"
65-
66-
curl -s -X POST \
67-
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
68-
-H "Accept: application/vnd.github.v3+json" \
69-
"$api_url" \
70-
-d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')"
24+
OPENAI_API_KEY: ${{ secrets.AI_API_KEY }}
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
GITHUB_REPOSITORY: ${{ github.repository }}
27+
ISSUE_NUMBER: ${{ github.event.issue.number }}
28+
ISSUE_REPO_URL: "https://github.com/${{ github.repository }}"
29+
run: ./ai-responder.py

0 commit comments

Comments
 (0)