Merge branch 'dev' into feature/test-ai-pr-action

This commit is contained in:
faris Aljohari
2025-07-15 23:48:01 -06:00

View File

@ -1,4 +1,4 @@
name: 🤖 AI PR Description Commenter (Safe JSON with PAT) name: 🤖 AI PR Description Commenter (100% Safe with jq)
on: on:
pull_request: pull_request:
@ -27,20 +27,21 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }} 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: | 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 \ RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{ -d "$REQUEST_BODY")
"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."
}]
}')
DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content') DESCRIPTION=$(echo "$RESPONSE" | jq -r '.choices[0].message.content')