Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/workflows/auto-fill-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ jobs:
id: ticket
run: |
BRANCH="${{ github.head_ref }}"
if [ -z "$BRANCH" ]; then
BRANCH="${{ github.ref }}"
BRANCH="${BRANCH#refs/heads/}"
fi
if [[ "$BRANCH" =~ ([Ii][Mm]-[0-9]+) ]]; then
TICKET="${BASH_REMATCH[1]^^}"
echo "ticket=$TICKET" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -226,8 +230,8 @@ jobs:
const existingBody = pr.body || '';

// Helper to check if a section is empty (only has comment placeholder)
const isSectionEmpty = (body, sectionHeader, nextHeader) => {
const sectionRegex = new RegExp(`## ${sectionHeader}\\s*([\\s\\S]*?)(?=## ${nextHeader}|$)`, 'i');
const isSectionEmpty = (body, sectionHeader) => {
const sectionRegex = new RegExp(`## ${sectionHeader}\\s*([\\s\\S]*?)(?=\\n## |$)`, 'i');
const match = body.match(sectionRegex);
if (!match) return true;
const content = match[1].trim();
Expand All @@ -237,7 +241,7 @@ jobs:

// Helper to check if any checkbox is checked in Type of Change
const hasCheckedType = (body) => {
const typeSection = body.match(/## Type of Change[\s\S]*?(?=## |$)/i);
const typeSection = body.match(/## Type of Change[\s\S]*?(?=\n## |$)/i);
if (!typeSection) return false;
return /\[x\]/i.test(typeSection[0]);
};
Expand All @@ -248,10 +252,10 @@ jobs:
const fileCount = parseInt(fs.readFileSync('/tmp/file_count.txt', 'utf8').trim());

// Determine what to fill
const fillDescription = isSectionEmpty(existingBody, 'Description', 'Ticket');
const fillTicket = isSectionEmpty(existingBody, 'Ticket', 'Type of Change');
const fillDescription = isSectionEmpty(existingBody, 'Description');
const fillTicket = isSectionEmpty(existingBody, 'Ticket');
const fillType = !hasCheckedType(existingBody) && changeType !== 'unknown';
const fillTesting = isSectionEmpty(existingBody, 'Testing Done', 'Checklist');
const fillTesting = isSectionEmpty(existingBody, 'Testing Done');

// Get description (Claude or fallback)
let description;
Expand Down Expand Up @@ -330,7 +334,7 @@ jobs:
// Add footer if we changed anything
const madeChanges = fillDescription || (fillTicket && ticketSection) || fillType || (fillTesting && testing);
if (madeChanges && !newBody.includes('Auto-generated by Claude') && !newBody.includes('Auto-filled')) {
const footer = claudeSuccess ? '\n---\n_✨ Auto-generated by Claude_' : '\n---\n_📝 Auto-filled_';
const footer = claudeSuccess ? '\n\n---\n_✨ Auto-generated by Claude_' : '\n\n---\n_📝 Auto-filled_';
newBody = newBody.trim() + footer;
}

Expand Down