mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-18 20:30:08 +08:00
Improve error handling in release workflow
Enhances the OpenRouter API call step by adding error handling for both curl and jq failures. If the API call or response parsing fails, the workflow now falls back to using a default release note template.
This commit is contained in:
parent
d32ccc6eb5
commit
75e1e8dd79
35
.github/workflows/release.yml
vendored
35
.github/workflows/release.yml
vendored
@ -232,25 +232,32 @@ jobs:
|
|||||||
echo "$BODY" | jq .
|
echo "$BODY" | jq .
|
||||||
|
|
||||||
# 调用 OpenRouter
|
# 调用 OpenRouter
|
||||||
RESPONSE=$(curl -s -X POST "$OPENROUTER_API_URL" \
|
if RESPONSE=$(curl -s -X POST "$OPENROUTER_API_URL" \
|
||||||
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
|
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$BODY")
|
-d "$BODY"); then
|
||||||
echo "=== raw response ==="
|
echo "=== raw response ==="
|
||||||
echo "$RESPONSE"
|
echo "$RESPONSE"
|
||||||
echo "=== OpenRouter raw response ==="
|
echo "=== OpenRouter raw response ==="
|
||||||
echo "$RESPONSE" | jq .
|
if echo "$RESPONSE" | jq . >/dev/null 2>&1; then
|
||||||
|
echo "$RESPONSE" | jq .
|
||||||
|
else
|
||||||
|
echo "jq failed to parse response"
|
||||||
|
fi
|
||||||
|
|
||||||
# 提取生成内容
|
# 提取生成内容
|
||||||
RELEASE_BODY=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // .choices[0].text // ""')
|
RELEASE_BODY=$(echo "$RESPONSE" | jq -r '.choices[0].message.content // .choices[0].text // ""' 2>/dev/null || echo "")
|
||||||
|
|
||||||
if [ -z "$RELEASE_BODY" ]; then
|
if [ -z "$RELEASE_BODY" ]; then
|
||||||
echo "❌ OpenRouter failed to generate release note, terminating workflow."
|
echo "❌ OpenRouter failed to generate release note, using default.md"
|
||||||
exit 1
|
cp .github/prompt/default.md CHANGELOG.md
|
||||||
|
else
|
||||||
|
echo -e "$RELEASE_BODY" > CHANGELOG.md
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "❌ Curl failed, using default.md"
|
||||||
|
cp .github/prompt/default.md CHANGELOG.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 输出到 CHANGELOG.md
|
|
||||||
echo -e "$RELEASE_BODY" > CHANGELOG.md
|
|
||||||
echo "=== generated release note ==="
|
echo "=== generated release note ==="
|
||||||
cat CHANGELOG.md
|
cat CHANGELOG.md
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user