mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
fix: update workflow name and enhance OpenAI request handling in AI PR Description
This commit is contained in:
21
.github/workflows/pr-description.yml
vendored
21
.github/workflows/pr-description.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: 🤖 AI PR Description Commenter (Safe JSON with PAT)
|
||||
name: 🤖 AI PR Description Commenter (100% Safe with jq)
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@ -27,20 +27,21 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
|
||||
|
||||
- name: Generate PR Description with OpenAI (Safe JSON)
|
||||
- name: Generate PR Description with OpenAI (Safe JSON with jq)
|
||||
run: |
|
||||
ESCAPED_COMMITS=$(printf '%s\n' "${commits}" | jq -R . | jq -s -c 'join("\n")')
|
||||
REQUEST_BODY=$(jq -n \
|
||||
--arg model "gpt-4o" \
|
||||
--arg content "Given the following commit messages:\n\n${commits}\n\nGenerate a clear and professional pull request description." \
|
||||
'{
|
||||
model: $model,
|
||||
messages: [{ role: "user", content: $content }]
|
||||
}'
|
||||
)
|
||||
|
||||
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
|
||||
-H "Authorization: Bearer $OPENAI_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"model": "gpt-4o",
|
||||
"messages": [{
|
||||
"role": "user",
|
||||
"content": "Given the following commit messages:\n\n'"${ESCAPED_COMMITS}"'\n\nGenerate a clear and professional pull request description."
|
||||
}]
|
||||
}')
|
||||
-d "$REQUEST_BODY")
|
||||
|
||||
DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')
|
||||
|
||||
|
Reference in New Issue
Block a user