@@ -402,77 +402,48 @@ runs:
402402
403403 DESCRIPTION=$(cat /tmp/template_work.txt)
404404 elif [ "$STYLE" = "minimal" ]; then
405- DESCRIPTION=$(cat <<DESC_EOF
406- # # Summary
407-
408- $SUMMARY
409-
410- # ## Files Changed
411-
412- $(cat /tmp/pr_files.txt 2>/dev/null || echo "None")
413-
414- ---
415-
416- # ##### 🤖 Generated by [DocuCraft](https://github.com/${{ github.repository }})
417- DESC_EOF
418- )
405+ {
406+ printf '## Summary\n\n'
407+ printf '%s\n\n' "$SUMMARY"
408+ printf '### Files Changed\n\n'
409+ cat /tmp/pr_files.txt 2>/dev/null || echo "None"
410+ printf '\n---\n\n'
411+ printf '###### 🤖 Generated by [DocuCraft](https://github.com/%s)\n' "${{ github.repository }}"
412+ } > /tmp/docucraft_desc.txt
413+ DESCRIPTION=$(cat /tmp/docucraft_desc.txt)
419414 elif [ "$STYLE" = "summary-only" ]; then
420- DESCRIPTION=$(cat <<DESC_EOF
421- # # Summary
422-
423- $SUMMARY
424-
425- ---
426-
427- # ##### 🤖 Generated by [DocuCraft](https://github.com/${{ github.repository }})
428- DESC_EOF
429- )
415+ {
416+ printf '## Summary\n\n'
417+ printf '%s\n\n' "$SUMMARY"
418+ printf '\n---\n\n'
419+ printf '###### 🤖 Generated by [DocuCraft](https://github.com/%s)\n' "${{ github.repository }}"
420+ } > /tmp/docucraft_desc.txt
421+ DESCRIPTION=$(cat /tmp/docucraft_desc.txt)
430422 elif [ "$STYLE" = "detailed" ]; then
431423 DIFF_PREVIEW=""
432424 if [ -f /tmp/pr_diff.txt ]; then
433425 DIFF_PREVIEW=$(head -c 3000 /tmp/pr_diff.txt)
434426 fi
435- DESCRIPTION=$(cat <<DESC_EOF
436- # # Summary
437-
438- $SUMMARY
439-
440- # ## Changes by Category
441- $CHANGES_SECTION
442-
443- # ## Diff Preview
444-
445- \`\`\`diff
446- $DIFF_PREVIEW
447- \`\`\`
448-
449- # ## Why
450-
451- Automated pull request description generated by DocuCraft. See diff preview above for detailed changes.
452-
453- ---
454-
455- # ##### 🤖 Generated by [DocuCraft](https://github.com/${{ github.repository }})
456- DESC_EOF
457- )
427+ {
428+ printf '## Summary\n\n'
429+ printf '%s\n\n' "$SUMMARY"
430+ printf '### Changes by Category\n'
431+ printf '%s\n\n' "$CHANGES_SECTION"
432+ printf '### Diff Preview\n\n```diff\n%s\n```\n\n' "$DIFF_PREVIEW"
433+ printf '### Why\n\nAutomated pull request description generated by DocuCraft. See diff preview above for detailed changes.\n\n---\n\n'
434+ printf '###### 🤖 Generated by [DocuCraft](https://github.com/%s)\n' "${{ github.repository }}"
435+ } > /tmp/docucraft_desc.txt
436+ DESCRIPTION=$(cat /tmp/docucraft_desc.txt)
458437 else
459- DESCRIPTION=$(cat <<DESC_EOF
460- # # Summary
461-
462- $SUMMARY
463-
464- # ## Changes by Category
465- $CHANGES_SECTION
466-
467- # ## Why
468-
469- Automated pull request description generated by DocuCraft. Review the diff for detailed changes.
470-
471- ---
472-
473- # ##### 🤖 Generated by [DocuCraft](https://github.com/${{ github.repository }})
474- DESC_EOF
475- )
438+ {
439+ printf '## Summary\n\n'
440+ printf '%s\n\n' "$SUMMARY"
441+ printf '### Changes by Category\n'
442+ printf '%s\n\n' "$CHANGES_SECTION"
443+ printf '### Why\n\nAutomated pull request description generated by DocuCraft. Review the diff for detailed changes.\n\n---\n\n'
444+ printf '###### 🤖 Generated by [DocuCraft](https://github.com/%s)\n' "${{ github.repository }}"
445+ } > /tmp/docucraft_desc.txt
446+ DESCRIPTION=$(cat /tmp/docucraft_desc.txt)
476447 fi
477448
478449 echo "description<<EOF" >> $GITHUB_OUTPUT
@@ -490,25 +461,14 @@ DESC_EOF
490461 FILES_LIST=$(cat /tmp/pr_files.txt 2>/dev/null || echo "No files detected")
491462 DIFF=$(cat /tmp/pr_diff.txt 2>/dev/null || echo "No diff available")
492463
493- PROMPT=$(cat <<PROMPT_EOF
494- You are DocuCraft, an expert code reviewer. Given this pull request, write a clear and concise PR description.
495-
496- PR Title : $PR_TITLE
497-
498- Files Changed :
499- $FILES_LIST
500-
501- Diff (truncated) :
502- \`\`\`diff
503- ${DIFF:0:8000}
504- \`\`\`
505-
506- Generate a PR description with markdown :
507- 1. **Summary** : 1-2 sentence overview
508- 2. **Changes** : Key changes organized by area
509- 3. **Why** : Motivation behind the changes
510- PROMPT_EOF
511- )
464+ {
465+ printf 'You are DocuCraft, an expert code reviewer. Given this pull request, write a clear and concise PR description.\n\n'
466+ printf 'PR Title: %s\n\n' "$PR_TITLE"
467+ printf 'Files Changed:\n%s\n\n' "$FILES_LIST"
468+ printf 'Diff (truncated):\n```diff\n%s\n```\n\n' "${DIFF:0:8000}"
469+ printf 'Generate a PR description with markdown:\n1. **Summary**: 1-2 sentence overview\n2. **Changes**: Key changes organized by area\n3. **Why**: Motivation behind the changes\n'
470+ } > /tmp/docucraft_prompt.txt
471+ PROMPT=$(cat /tmp/docucraft_prompt.txt)
512472 JSON_ESCAPED=$(echo "$PROMPT" | jq -Rs .)
513473 RESPONSE=$(curl -s https://api.openai.com/v1/chat/completions \
514474 -H "Authorization: Bearer $OPENAI_API_KEY" \
@@ -535,20 +495,16 @@ PROMPT_EOF
535495 PR_LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '[.labels[].name] | join(", ")' 2>/dev/null || echo "")
536496 MERGE_COMMIT="${{ github.event.pull_request.merge_commit_sha }}"
537497
538- CHANGELOG=$(cat <<CHLOG_EOF
539- # ## [#$PR_NUMBER] - $DATE
540- $PR_TITLE
541-
542- **Labels:** ${PR_LABELS:-none}
543-
544- **Merge Commit:** $MERGE_COMMIT
545-
546- **Files:**
547- $(cat /tmp/pr_files.txt 2>/dev/null | sed 's/^/- /')
548-
549- ---
550- CHLOG_EOF
551- )
498+ {
499+ printf '### [#%s] - %s\n' "$PR_NUMBER" "$DATE"
500+ printf '%s\n\n' "$PR_TITLE"
501+ printf '**Labels:** %s\n\n' "${PR_LABELS:-none}"
502+ printf '**Merge Commit:** %s\n\n' "$MERGE_COMMIT"
503+ printf '**Files:**\n'
504+ cat /tmp/pr_files.txt 2>/dev/null | sed 's/^/- /'
505+ printf '\n---\n'
506+ } > /tmp/docucraft_changelog.txt
507+ CHANGELOG=$(cat /tmp/docucraft_changelog.txt)
552508 echo "changelog_entry<<EOF" >> $GITHUB_OUTPUT
553509 echo "$CHANGELOG" >> $GITHUB_OUTPUT
554510 echo "EOF" >> $GITHUB_OUTPUT
0 commit comments