Skip to content

Commit 830adc9

Browse files
committed
Add or update GitHub Actions workflows
1 parent f51c5ba commit 830adc9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

.github/workflows/ai-responder.yml

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

34
on:
@@ -24,7 +25,9 @@ jobs:
2425
env:
2526
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
2627
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+
2831
title="${{ steps.get_issue.outputs.title }}"
2932
body="${{ steps.get_issue.outputs.body }}"
3033
@@ -41,17 +44,25 @@ jobs:
4144
temperature: 0.5
4245
}')
4346
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" \
4754
-d "$json" | jq -r '.choices[0].message.content')
4855
4956
echo "reply=$response" >> "$GITHUB_OUTPUT"
5057
5158
- name: Reply to issue
5259
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+
5364
curl -s -X POST \
5465
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
5566
-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

Comments
 (0)