Skip to content

Commit 3c88d82

Browse files
committed
feat: PR summary generation with categorized changes and titles
1 parent b19a0fd commit 3c88d82

1 file changed

Lines changed: 26 additions & 69 deletions

File tree

.github/workflows/arduino-compile.yml

Lines changed: 26 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ jobs:
714714
715715
# Build the prompt
716716
read -r -d '' PROMPT << 'EOF'
717-
You are a code review assistant. Analyze the following pull request and provide a comprehensive summary.
717+
You are a code review assistant. Analyze the following pull request and provide a categorized summary of changes.
718718
719719
**IMPORTANT:** Focus ONLY on the actual code changes listed below. Do NOT mention or summarize any GitHub Actions workflow files (.github/workflows/) as those have been filtered out.
720720
@@ -729,10 +729,7 @@ jobs:
729729
%FILES%
730730
731731
## Your Task
732-
Provide a well-structured summary with these sections:
733-
734-
### 📋 Overview
735-
Write 2-3 sentences describing what this PR accomplishes overall.
732+
Provide ONLY the following section in clean markdown format:
736733
737734
### 🔄 Changes by Category
738735
Group the changes into relevant categories such as:
@@ -745,20 +742,7 @@ jobs:
745742
- **Configuration**: Config file changes
746743
747744
Only include categories that apply. Use bullet points for each change.
748-
749-
### ⚠️ Notable Details
750-
Highlight any:
751-
- Breaking changes
752-
- Security considerations
753-
- Performance implications
754-
- Migration requirements
755-
756-
If none, write "No notable concerns identified."
757-
758-
### 👀 Suggested Review Focus
759-
List 2-4 specific areas or files reviewers should pay close attention to.
760-
761-
Format everything in clean markdown.
745+
Do NOT include any other sections, headers, or conclusions.
762746
EOF
763747
764748
# Replace placeholders (remove jq quotes)
@@ -828,62 +812,35 @@ jobs:
828812
pull_number: context.issue.number,
829813
});
830814
831-
// Create enhanced PR body with AI summary
832-
const marker = '<!-- pr-commit-summary-bot -->';
833-
const summarySection = `${marker}
834-
835-
${summary}
815+
// Create PR body with only Changes by Category section
816+
const newBody = `${summary}
836817
837818
---
838-
<sub>📊 Analyzed **${commitCount}** commit(s) | 🕐 Updated: ${timestamp} | Generated by GitHub Actions</sub>
819+
<sub>📊 Analyzed **${commitCount}** commit(s) | 🕐 Updated: ${timestamp} | Generated by GitHub Actions</sub>`;
839820
840-
---
841-
`;
821+
// Generate title with emoji prefix (replace existing)
822+
const titleLower = pr.title.toLowerCase();
823+
let emoji = '✨'; // Default: sparkles for feature
842824
843-
// Check if the PR body already has our summary marker
844-
let newBody;
845-
if (pr.body && pr.body.includes(marker)) {
846-
// Replace existing summary section
847-
const markerIndex = pr.body.indexOf(marker);
848-
const endMarkerIndex = pr.body.indexOf('---\n\n', markerIndex + summarySection.length);
849-
850-
if (endMarkerIndex !== -1) {
851-
// Replace everything from marker to the end of summary section
852-
newBody = pr.body.substring(0, markerIndex) + summarySection + pr.body.substring(endMarkerIndex + 5);
853-
} else {
854-
// Fallback: append new summary
855-
newBody = summarySection + (pr.body || '');
856-
}
857-
} else {
858-
// Prepend summary to existing body
859-
newBody = summarySection + (pr.body || '');
825+
if (titleLower.includes('fix') || titleLower.includes('bug')) {
826+
emoji = '🐛';
827+
} else if (titleLower.includes('doc')) {
828+
emoji = '📚';
829+
} else if (titleLower.includes('refactor') || titleLower.includes('cleanup')) {
830+
emoji = '♻️';
831+
} else if (titleLower.includes('test')) {
832+
emoji = '✅';
833+
} else if (titleLower.includes('config') || titleLower.includes('setting')) {
834+
emoji = '⚙️';
835+
} else if (titleLower.includes('security')) {
836+
emoji = '🔒';
837+
} else if (titleLower.includes('performance') || titleLower.includes('optim')) {
838+
emoji = '⚡';
860839
}
861840
862-
// Generate enhanced title with emoji prefix if not already present
863-
let newTitle = pr.title;
864-
if (!pr.title.match(/^[\u{1F300}-\u{1F9FF}]/u)) {
865-
// Add a relevant emoji based on keywords in the title
866-
const titleLower = pr.title.toLowerCase();
867-
let emoji = '✨'; // Default: sparkles for feature
868-
869-
if (titleLower.includes('fix') || titleLower.includes('bug')) {
870-
emoji = '🐛';
871-
} else if (titleLower.includes('doc')) {
872-
emoji = '📚';
873-
} else if (titleLower.includes('refactor') || titleLower.includes('cleanup')) {
874-
emoji = '♻️';
875-
} else if (titleLower.includes('test')) {
876-
emoji = '✅';
877-
} else if (titleLower.includes('config') || titleLower.includes('setting')) {
878-
emoji = '⚙️';
879-
} else if (titleLower.includes('security')) {
880-
emoji = '🔒';
881-
} else if (titleLower.includes('performance') || titleLower.includes('optim')) {
882-
emoji = '⚡';
883-
}
884-
885-
newTitle = `${emoji} ${pr.title}`;
886-
}
841+
// Remove any existing emoji prefix and add new one
842+
const cleanTitle = pr.title.replace(/^[\u{1F300}-\u{1F9FF}]\s*/u, '');
843+
const newTitle = `${emoji} ${cleanTitle}`;
887844
888845
// Update the PR
889846
await github.rest.pulls.update({

0 commit comments

Comments
 (0)