fix: update workflow name and enhance commit message handling in AI PR Description

This commit is contained in:
faris Aljohari
2025-07-15 23:45:16 -06:00
parent 6d2252a403
commit f0556813ac

View File

@ -1,4 +1,4 @@
name: 🤖 AI PR Description Commenter (With Debug)
name: 🤖 AI PR Description Commenter (Safe JSON with PAT)
on:
pull_request:
@ -12,10 +12,10 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install GitHub CLI
- name: Install GitHub CLI and jq
run: |
sudo apt-get update
sudo apt-get install gh -y
sudo apt-get install gh jq -y
- name: Fetch PR Commits
id: fetch_commits
@ -27,9 +27,10 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
- name: Generate PR Description with OpenAI
id: generate_description
- name: Generate PR Description with OpenAI (Safe JSON)
run: |
ESCAPED_COMMITS=$(printf '%s\n' "${commits}" | jq -R . | jq -s -c 'join("\n")')
RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
@ -37,7 +38,7 @@ jobs:
"model": "gpt-4o",
"messages": [{
"role": "user",
"content": "Given the following commit messages:\n\n'"${commits}"'\n\nGenerate a clear and professional pull request description."
"content": "Given the following commit messages:\n\n'"${ESCAPED_COMMITS}"'\n\nGenerate a clear and professional pull request description."
}]
}')