Skip to content

Commit 72ddc4e

Browse files
Copilotmazhelez
andcommitted
Add manual workflow to comment on existing release notes PRs
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
1 parent 3804759 commit 72ddc4e

3 files changed

Lines changed: 122 additions & 6 deletions

File tree

.github/scripts/README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ This PowerShell script adds a reminder comment to all open PRs that modify the `
88

99
### Usage
1010

11+
**Option 1: Use the GitHub Workflow (Recommended)**
12+
13+
The easiest way to add comments to existing PRs is to use the manual workflow:
14+
15+
1. Go to the Actions tab in the repository
16+
2. Select "Comment on Existing Release Notes PRs" workflow
17+
3. Click "Run workflow"
18+
4. Choose whether to run in dry-run mode (to preview which PRs will be commented)
19+
5. Click "Run workflow"
20+
21+
**Option 2: Run the PowerShell Script Locally**
22+
1123
```powershell
1224
# Set your GitHub token as an environment variable
1325
$env:GITHUB_TOKEN = "your-github-token-here"
@@ -37,4 +49,4 @@ pwsh .github/scripts/comment-on-existing-release-notes-prs.ps1
3749

3850
### Note
3951

40-
For new PRs, the automated workflow `.github/workflows/check-release-notes-prs.yml` will automatically add the comment. This script is only needed to handle existing open PRs at the time of deployment.
52+
For new PRs, the automated workflow `.github/workflows/check-release-notes-prs.yml` will automatically add the comment. This script/workflow is only needed to handle existing open PRs at the time of deployment.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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}`);

docs/release-notes-pr-automation.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,27 @@ This workflow automatically triggers when a PR is opened, updated, or reopened i
3232

3333
### 2. One-Time Script for Existing PRs
3434

35-
**File**: `.github/scripts/comment-on-existing-release-notes-prs.ps1`
35+
**Files**:
36+
- `.github/scripts/comment-on-existing-release-notes-prs.ps1` (PowerShell script)
37+
- `.github/workflows/comment-on-existing-release-notes-prs.yml` (Manual workflow)
3638

37-
This PowerShell script is designed to be run once to add comments to all currently open PRs that modify `RELEASENOTES.md`. After the initial run, the automated workflow handles new PRs.
39+
These are designed to be run once to add comments to all currently open PRs that modify `RELEASENOTES.md`. After the initial run, the automated workflow handles new PRs.
3840

39-
**Usage:**
41+
**Usage (Recommended - Manual Workflow):**
42+
1. Go to the Actions tab in the repository
43+
2. Select "Comment on Existing Release Notes PRs" workflow
44+
3. Click "Run workflow"
45+
4. Choose whether to run in dry-run mode (preview only)
46+
5. Click "Run workflow" to execute
47+
48+
**Usage (Alternative - PowerShell Script):**
4049
```powershell
4150
$env:GITHUB_TOKEN = "your-token-here"
4251
pwsh .github/scripts/comment-on-existing-release-notes-prs.ps1
4352
```
4453

45-
The script:
46-
1. Fetches all open PRs
54+
What it does:
55+
1. Fetches all open PRs (or uses a predefined list)
4756
2. Checks which ones modify `RELEASENOTES.md`
4857
3. Adds the reminder comment (if not already present)
4958

0 commit comments

Comments
 (0)