mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-08-26 03:29:41 +00:00
fix: update workflow name and enhance commit message handling in AI PR Description
This commit is contained in:
13
.github/workflows/pr-description.yml
vendored
13
.github/workflows/pr-description.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: 🤖 AI PR Description Commenter (With Debug)
|
name: 🤖 AI PR Description Commenter (Safe JSON with PAT)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
@ -12,10 +12,10 @@ jobs:
|
|||||||
- name: Checkout Repo
|
- name: Checkout Repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install GitHub CLI
|
- name: Install GitHub CLI and jq
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install gh -y
|
sudo apt-get install gh jq -y
|
||||||
|
|
||||||
- name: Fetch PR Commits
|
- name: Fetch PR Commits
|
||||||
id: fetch_commits
|
id: fetch_commits
|
||||||
@ -27,9 +27,10 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
|
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
- name: Generate PR Description with OpenAI
|
- name: Generate PR Description with OpenAI (Safe JSON)
|
||||||
id: generate_description
|
|
||||||
run: |
|
run: |
|
||||||
|
ESCAPED_COMMITS=$(printf '%s\n' "${commits}" | jq -R . | jq -s -c 'join("\n")')
|
||||||
|
|
||||||
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" \
|
||||||
@ -37,7 +38,7 @@ jobs:
|
|||||||
"model": "gpt-4o",
|
"model": "gpt-4o",
|
||||||
"messages": [{
|
"messages": [{
|
||||||
"role": "user",
|
"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."
|
||||||
}]
|
}]
|
||||||
}')
|
}')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user