1
+ ---
1
2
name : AI Issue Responder
2
3
3
4
on :
24
25
env :
25
26
OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
26
27
run : |
27
- prompt="You're a helpful AI assistant. Reply concisely to the following GitHub issue."
28
+ prompt="You're a helpful AI assistant. "
29
+ prompt+="Reply concisely to the following GitHub issue."
30
+
28
31
title="${{ steps.get_issue.outputs.title }}"
29
32
body="${{ steps.get_issue.outputs.body }}"
30
33
@@ -41,17 +44,25 @@ jobs:
41
44
temperature: 0.5
42
45
}')
43
46
44
- response=$(curl -s https://api.openai.com/v1/chat/completions \
45
- -H "Authorization: Bearer $OPENAI_API_KEY" \
46
- -H "Content-Type: application/json" \
47
+ api_url="https://api.openai.com/v1/chat/completions"
48
+ auth="Authorization: Bearer $OPENAI_API_KEY"
49
+ ctype="Content-Type: application/json"
50
+
51
+ response=$(curl -s "$api_url" \
52
+ -H "$auth" \
53
+ -H "$ctype" \
47
54
-d "$json" | jq -r '.choices[0].message.content')
48
55
49
56
echo "reply=$response" >> "$GITHUB_OUTPUT"
50
57
51
58
- name : Reply to issue
52
59
run : |
60
+ comment="${{ steps.ai.outputs.reply }}"
61
+ api_url="https://api.github.com/repos/${{ github.repository }}"
62
+ api_url+="/issues/${{ github.event.issue.number }}/comments"
63
+
53
64
curl -s -X POST \
54
65
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
55
66
-H "Accept: application/vnd.github.v3+json" \
56
- https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
57
- -d "$(jq -n --arg body "${{ steps.ai.outputs.reply }} " '{body: $body}')"
67
+ "$api_url" \
68
+ -d "$(jq -n --arg body "$comment " '{body: $body}')"
0 commit comments