@@ -1420,7 +1420,7 @@ jobs:
1420
1420
1421
1421
# Get Renovate release notes from PR body, massage a little and draft a comment.
1422
1422
- name : Format release notes
1423
- id : format_release_notes
1423
+ id : format_release_notes_old
1424
1424
continue-on-error : true
1425
1425
env :
1426
1426
# We need pull_requests: read to get the PR title and body but that permission
@@ -1496,6 +1496,82 @@ jobs:
1496
1496
fi
1497
1497
fi
1498
1498
1499
+ # Get Renovate release notes from PR body, massage a little and draft a comment.
1500
+ - name : Format release notes
1501
+ id : format_release_notes
1502
+ continue-on-error : true
1503
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
1504
+ with :
1505
+ github-token : ${{ steps.gh_app_token.outputs.token || secrets.FLOWZONE_TOKEN }}
1506
+ result-encoding : string
1507
+ script : |
1508
+ const { data: pr } = await github.rest.pulls.get({
1509
+ owner: context.repo.owner,
1510
+ repo: context.repo.repo,
1511
+ pull_number: context.issue.number
1512
+ });
1513
+
1514
+ console.log('pr:', JSON.stringify(pr, null, 2));
1515
+
1516
+ if (!pr.title) {
1517
+ return;
1518
+ }
1519
+
1520
+ // Check if PR is from Renovate
1521
+ const isRenovate = pr.user.type === 'Bot' && pr.user.login.includes('renovate');
1522
+ const hasReleaseNotes = pr.body.includes('### Release Notes');
1523
+
1524
+ if (isRenovate && hasReleaseNotes) {
1525
+ // Extract release notes section
1526
+ const releaseNotesMatch = pr.body.match(/### Release Notes\n([\s\S]*?)---/);
1527
+ if (releaseNotesMatch) {
1528
+ const prBody = releaseNotesMatch[1].trim();
1529
+
1530
+ // Extract notable changes
1531
+ const notableChanges = prBody
1532
+ .split('\n')
1533
+ .filter(line => line.match(/^> -|^-|^<summary>/))
1534
+ .map(line => line.replace(/^<summary>(.*)<\/summary>/, '-$1'))
1535
+ .filter((line, index, self) => self.indexOf(line) === index)
1536
+ .slice(1);
1537
+
1538
+ // Format release notes
1539
+ const releaseNotesChanges = notableChanges
1540
+ .map(line => line.replace(/^> -(.*)/, ' -$1'))
1541
+ .join('\n');
1542
+
1543
+ const releaseNotes = `## ${pr.title}\n\n### Notable changes\n\n${releaseNotesChanges}\n\n${prBody}`;
1544
+ core.setOutput('body', releaseNotes);
1545
+
1546
+ // Format comment
1547
+ const notableChangesFormatted = notableChanges
1548
+ .map(line => `* ${line.replace(/^> -|^-/, '')}`)
1549
+ .join('\n');
1550
+
1551
+ const releaseNotesComment = `#release-notes ${pr.title}\n\nNotable changes\n* [only keep the important and rephrase, leaving this in place will avoid posting release notes]\n${notableChangesFormatted}\n\n${prBody}`;
1552
+ core.setOutput('comment', releaseNotesComment);
1553
+
1554
+ return releaseNotes;
1555
+ }
1556
+ }
1557
+
1558
+ console.log('match:', pr.body.match(/## Release Notes/i));
1559
+
1560
+ // Handle non-Renovate cases
1561
+ if (pr.body.match(/## Release Notes/i)) {
1562
+
1563
+ const releaseNotesMatch = pr.body.match(/## Release Notes\n([\s\S]*?)(?=## |$)/i);
1564
+ if (releaseNotesMatch) {
1565
+ const releaseNotesBody = releaseNotesMatch[1].trim();
1566
+
1567
+ const releaseNotes = `## ${pr.title}\n${releaseNotesBody}`;
1568
+ core.setOutput('body', releaseNotes);
1569
+
1570
+ return releaseNotes;
1571
+ }
1572
+ }
1573
+
1574
+
1499
1575
# https://octokit.github.io/rest.js/v21/#repos-list-tags
1500
1576
# https://docs.github.com/en/rest/git/refs
1501
1577
# https://octokit.github.io/rest.js/v21/#repos-compare-commits-with-basehead
0 commit comments