Skip to content

Commit 10ed6d3

Browse files
authored
Refactor: review submission process in workflow
1 parent cfa5f79 commit 10ed6d3

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

.github/workflows/translate-review.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,23 @@ jobs:
407407
'{body: $body, commit_id: $commit_id, event: $event, comments: $comments}')
408408
409409
echo "Submitting review (with inline comments)..."
410-
REVIEW_RESP=$(mktemp)
411-
REVIEW_CODE=$(gh api --method POST \
410+
REVIEW_OUT=$(mktemp)
411+
REVIEW_ERR=$(mktemp)
412+
if gh api --method POST \
412413
-H "Accept: application/vnd.github+json" \
413414
"/repos/$REPO/pulls/$PR_NUMBER/reviews" \
414-
--input - <<< "$REVIEW_PAYLOAD" 2>"$REVIEW_RESP" && echo 200 || echo "$?")
415-
if [ "$REVIEW_CODE" != "200" ]; then
416-
echo "::warning::Review API 실패 ($REVIEW_CODE): $(cat "$REVIEW_RESP" | head -c 500)"
415+
--input - <<< "$REVIEW_PAYLOAD" >"$REVIEW_OUT" 2>"$REVIEW_ERR"; then
416+
REVIEW_OK=1
417+
else
418+
REVIEW_OK=0
419+
REVIEW_RC=$?
420+
fi
421+
if [ "$REVIEW_OK" = "1" ]; then
422+
REVIEW_ID=$(jq -r '.id // empty' "$REVIEW_OUT" 2>/dev/null)
423+
REVIEW_URL=$(jq -r '.html_url // empty' "$REVIEW_OUT" 2>/dev/null)
424+
echo "✅ Inline review posted (id=${REVIEW_ID:-?}) ${REVIEW_URL}"
425+
else
426+
echo "::warning::Review API 실패 (rc=${REVIEW_RC:-?}): $(head -c 500 "$REVIEW_ERR")"
417427
echo "→ 요약 + 인라인 후보 목록을 일반 코멘트로 폴백"
418428
FALLBACK_LIST=$(echo "$REVIEW_COMMENTS" | jq -r '[.[] | "- `" + .path + ":" + (.line|tostring) + "` " + (.body|split("\n")[0])] | .[]')
419429
FALLBACK_BODY="$REVIEW_BODY
@@ -422,7 +432,7 @@ jobs:
422432
$FALLBACK_LIST"
423433
gh pr comment "$PR_NUMBER" --body "$FALLBACK_BODY"
424434
fi
425-
rm -f "$REVIEW_RESP"
435+
rm -f "$REVIEW_OUT" "$REVIEW_ERR"
426436
else
427437
echo "No valid-line comments left, posting summary only..."
428438
gh pr comment "$PR_NUMBER" --body "$REVIEW_BODY

0 commit comments

Comments
 (0)