|
| 1 | +name: Comment on Existing Release Notes PRs |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + dryRun: |
| 7 | + description: 'Dry run mode (only list PRs, do not add comments)' |
| 8 | + required: false |
| 9 | + default: 'false' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - 'true' |
| 13 | + - 'false' |
| 14 | + |
| 15 | +permissions: |
| 16 | + pull-requests: write |
| 17 | + contents: read |
| 18 | + issues: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + comment-on-prs: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Add Comments to Existing PRs |
| 25 | + uses: actions/github-script@v7 |
| 26 | + with: |
| 27 | + script: | |
| 28 | + const dryRun = '${{ inputs.dryRun }}' === 'true'; |
| 29 | + |
| 30 | + // PRs that modify RELEASENOTES.md |
| 31 | + const prs = [2056, 2049, 2048, 2047, 2041, 2033, 2031, 2029, 2010, 1994, 1882, 1828, 1824, 1795]; |
| 32 | + |
| 33 | + const comment = `### ⚠️ Release Notes Update Reminder |
| 34 | +
|
| 35 | +Thank you for updating the release notes! |
| 36 | + |
| 37 | +Please ensure that your changes are placed **above the new version section** (currently \`## v8.1\`) in the RELEASENOTES.md file. |
| 38 | + |
| 39 | +This helps maintain a clear changelog structure where new changes are grouped under the latest unreleased version.`; |
| 40 | + |
| 41 | + console.log(`Processing ${prs.length} PRs...`); |
| 42 | + console.log(`Dry run mode: ${dryRun}`); |
| 43 | + console.log(''); |
| 44 | + |
| 45 | + let commented = 0; |
| 46 | + let skipped = 0; |
| 47 | + let failed = 0; |
| 48 | + |
| 49 | + for (const prNumber of prs) { |
| 50 | + try { |
| 51 | + console.log(`Checking PR #${prNumber}...`); |
| 52 | + |
| 53 | + // Check if comment already exists |
| 54 | + const comments = await github.rest.issues.listComments({ |
| 55 | + owner: context.repo.owner, |
| 56 | + repo: context.repo.repo, |
| 57 | + issue_number: prNumber, |
| 58 | + }); |
| 59 | + |
| 60 | + const alreadyCommented = comments.data.some(c => |
| 61 | + c.body && c.body.includes('Release Notes Update Reminder') |
| 62 | + ); |
| 63 | + |
| 64 | + if (alreadyCommented) { |
| 65 | + console.log(` ℹ️ Comment already exists on PR #${prNumber}, skipping...`); |
| 66 | + skipped++; |
| 67 | + continue; |
| 68 | + } |
| 69 | + |
| 70 | + if (dryRun) { |
| 71 | + console.log(` [DRY RUN] Would add comment to PR #${prNumber}`); |
| 72 | + commented++; |
| 73 | + } else { |
| 74 | + // Add comment |
| 75 | + await github.rest.issues.createComment({ |
| 76 | + owner: context.repo.owner, |
| 77 | + repo: context.repo.repo, |
| 78 | + issue_number: prNumber, |
| 79 | + body: comment |
| 80 | + }); |
| 81 | + console.log(` ✓ Comment added to PR #${prNumber}`); |
| 82 | + commented++; |
| 83 | + } |
| 84 | + } catch (error) { |
| 85 | + console.log(` ✗ Failed to process PR #${prNumber}: ${error.message}`); |
| 86 | + failed++; |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + console.log(''); |
| 91 | + console.log('Summary:'); |
| 92 | + console.log(` Total PRs processed: ${prs.length}`); |
| 93 | + console.log(` Comments added: ${commented}`); |
| 94 | + console.log(` Skipped (already commented): ${skipped}`); |
| 95 | + console.log(` Failed: ${failed}`); |
0 commit comments