1
- ---
2
1
name : AI Issue Responder
3
2
4
3
on :
@@ -16,25 +15,27 @@ jobs:
16
15
steps :
17
16
- name : Get issue content
18
17
id : get_issue
18
+ env :
19
+ ISSUE_TITLE : ${{ github.event.issue.title }}
20
+ ISSUE_BODY : ${{ github.event.issue.body }}
19
21
run : |
20
- echo "title=${{ github.event.issue.title }} " >> "$GITHUB_OUTPUT"
21
- echo "body=${{ github.event.issue.body }} " >> "$GITHUB_OUTPUT"
22
+ echo "title=$ISSUE_TITLE " >> "$GITHUB_OUTPUT"
23
+ echo "body=$ISSUE_BODY " >> "$GITHUB_OUTPUT"
22
24
23
25
- name : Call OpenAI API
24
26
id : ai
25
27
env :
26
28
OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
29
+ ISSUE_TITLE : ${{ steps.get_issue.outputs.title }}
30
+ ISSUE_BODY : ${{ steps.get_issue.outputs.body }}
27
31
run : |
28
32
prompt="You're a helpful AI assistant. "
29
33
prompt+="Reply concisely to the following GitHub issue."
30
34
31
- title="${{ steps.get_issue.outputs.title }}"
32
- body="${{ steps.get_issue.outputs.body }}"
33
-
34
35
json=$(jq -n \
35
36
--arg model "gpt-4o" \
36
37
--arg system "$prompt" \
37
- --arg user "$title - $body " \
38
+ --arg user "$ISSUE_TITLE - $ISSUE_BODY " \
38
39
'{
39
40
model: $model,
40
41
messages: [
@@ -56,13 +57,14 @@ jobs:
56
57
echo "reply=$response" >> "$GITHUB_OUTPUT"
57
58
58
59
- name : Reply to issue
60
+ env :
61
+ COMMENT_BODY : ${{ steps.ai.outputs.reply }}
59
62
run : |
60
- comment="${{ steps.ai.outputs.reply }}"
61
63
api_url="https://api.github.com/repos/${{ github.repository }}"
62
64
api_url+="/issues/${{ github.event.issue.number }}/comments"
63
65
64
66
curl -s -X POST \
65
67
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
66
68
-H "Accept: application/vnd.github.v3+json" \
67
69
"$api_url" \
68
- -d "$(jq -n --arg body "$comment " '{body: $body}')"
70
+ -d "$(jq -n --arg body "$COMMENT_BODY " '{body: $body}')"
0 commit comments