Skip to content

Commit 87760d7

Browse files
committed
Add or update GitHub Actions workflows
1 parent 91d7d37 commit 87760d7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

.github/workflows/ai-responder.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
name: AI Issue Responder
32

43
on:
@@ -16,25 +15,27 @@ jobs:
1615
steps:
1716
- name: Get issue content
1817
id: get_issue
18+
env:
19+
ISSUE_TITLE: ${{ github.event.issue.title }}
20+
ISSUE_BODY: ${{ github.event.issue.body }}
1921
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"
2224
2325
- name: Call OpenAI API
2426
id: ai
2527
env:
2628
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
29+
ISSUE_TITLE: ${{ steps.get_issue.outputs.title }}
30+
ISSUE_BODY: ${{ steps.get_issue.outputs.body }}
2731
run: |
2832
prompt="You're a helpful AI assistant. "
2933
prompt+="Reply concisely to the following GitHub issue."
3034
31-
title="${{ steps.get_issue.outputs.title }}"
32-
body="${{ steps.get_issue.outputs.body }}"
33-
3435
json=$(jq -n \
3536
--arg model "gpt-4o" \
3637
--arg system "$prompt" \
37-
--arg user "$title - $body" \
38+
--arg user "$ISSUE_TITLE - $ISSUE_BODY" \
3839
'{
3940
model: $model,
4041
messages: [
@@ -56,13 +57,14 @@ jobs:
5657
echo "reply=$response" >> "$GITHUB_OUTPUT"
5758
5859
- name: Reply to issue
60+
env:
61+
COMMENT_BODY: ${{ steps.ai.outputs.reply }}
5962
run: |
60-
comment="${{ steps.ai.outputs.reply }}"
6163
api_url="https://api.github.com/repos/${{ github.repository }}"
6264
api_url+="/issues/${{ github.event.issue.number }}/comments"
6365
6466
curl -s -X POST \
6567
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
6668
-H "Accept: application/vnd.github.v3+json" \
6769
"$api_url" \
68-
-d "$(jq -n --arg body "$comment" '{body: $body}')"
70+
-d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')"

0 commit comments

Comments
 (0)