Skip to content

Commit bcdb097

Browse files
authored
Update GHES release note scripts (#62205)
1 parent 5648681 commit bcdb097

4 files changed

Lines changed: 41 additions & 316 deletions

File tree

.github/workflows/notify-release-pms.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,27 @@ on:
3636

3737
permissions:
3838
contents: read
39+
pull-requests: read
3940

4041
jobs:
4142
notify:
4243
name: Notify release PMs
4344
if: github.repository == 'github/docs-internal'
4445
runs-on: ubuntu-latest
4546
steps:
47+
- name: Get PR head branch
48+
id: pr-ref
49+
env:
50+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
PR_NUMBER: ${{ inputs.pr }}
52+
run: |
53+
ref=$(gh pr view "$PR_NUMBER" --repo github/docs-internal --json headRefName --jq '.headRefName')
54+
echo "ref=$ref" >> "$GITHUB_OUTPUT"
55+
4656
- name: Checkout repository code
4757
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
58+
with:
59+
ref: ${{ steps.pr-ref.outputs.ref }}
4860

4961
- uses: ./.github/actions/node-npm-setup
5062

src/ghes-releases/scripts/check-release-approvals.ts

Lines changed: 0 additions & 269 deletions
This file was deleted.

src/ghes-releases/scripts/notify-release-pms.ts

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -113,63 +113,37 @@ function extractSourceNotes(yamlPath: string): SourceNote[] {
113113
return parseSourceNotes(content)
114114
}
115115

116-
/**
117-
* Calculate the next weekday (Mon–Fri) at least `days` calendar days from now.
118-
* If the resulting date lands on a weekend, it rolls forward to Monday.
119-
*/
120-
function getReviewDeadline(days: number): string {
121-
const date = new Date()
122-
date.setDate(date.getDate() + days)
123-
const day = date.getDay()
124-
if (day === 0) date.setDate(date.getDate() + 1) // Sunday → Monday
125-
if (day === 6) date.setDate(date.getDate() + 2) // Saturday → Monday
126-
return date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' })
127-
}
128-
129116
/**
130117
* Build the comment body for a release issue notification.
131118
*/
132119
export function buildCommentBody(
133120
version: string,
134121
rc: boolean,
135122
prNumber: number,
136-
relativeFilePath: string,
137-
reviewDate?: string,
123+
assignees: string[],
138124
): string {
139125
const releaseType = rc ? 'RC' : 'GA'
140126
const prUrl = `https://github.com/github/docs-internal/pull/${prNumber}`
141127
const fileUrl = `${prUrl}/files`
142-
const deadline = reviewDate
143-
? new Date(`${reviewDate}T00:00:00`).toLocaleDateString('en-US', {
144-
month: 'long',
145-
day: 'numeric',
146-
year: 'numeric',
147-
})
148-
: getReviewDeadline(10)
149-
150-
// Use a marker so we can identify our comments later (for check-release-approvals).
128+
129+
// Use a marker so we can identify our comments later (for duplicate-prevention).
151130
// Include releaseType so RC and GA comments are distinguishable.
152131
const marker = buildMarker(version, releaseType.toLowerCase() as 'rc' | 'ga')
153132

133+
const mentions = assignees.length > 0 ? `${assignees.map((a) => `@${a}`).join(' ')} ` : ''
134+
154135
return `${marker}
155136
### GHES ${version} ${releaseType} release note review
156137
157-
Hello! A release note has been created for this feature by the Docs team assisted by Copilot. If you'd like to review it:
158-
159-
1. [**Review the note in the PR**](${fileUrl}) (search for this issue's URL within \`${relativeFilePath}\`)
160-
2. If the note looks good, **react to this comment with 🚀**.
161-
3. If it needs changes, suggest edits directly in the PR, then **react with 🚀** to this comment when you're done.
138+
👋 ${mentions}A Copilot-generated release note has been added in [docs-internal PR #${prNumber}](${fileUrl}).
162139
163-
We ask that you submit any changes by **${deadline}** to help ensure timely release notes.
140+
You're welcome to edit it in the PR. If you do nothing, the note will be published after review from a Docs team member.
164141
165-
The 🚀 tells us you've completed your review. If we don't hear from you, we'll go ahead with this note.
166-
167-
If you think this issue should **not** have a release note, please let us know in [#docs-ghes-releases](https://github-grid.enterprise.slack.com/archives/C0AQ37XBK7D).`
142+
Any questions, ask in [#docs-ghes-releases](https://github-grid.enterprise.slack.com/archives/C0AQ37XBK7D).`
168143
}
169144

170145
/**
171146
* Build the marker string used to identify notification comments.
172-
* Must stay in sync with check-release-approvals.
173147
*/
174148
export function buildMarker(version: string, releaseType: 'rc' | 'ga'): string {
175149
return `<!-- ghes-release-note-review: ${version}-${releaseType} -->`
@@ -339,7 +313,21 @@ program
339313

340314
for (let i = 0; i < toNotify.length; i++) {
341315
const note = toNotify[i]
342-
const commentBody = buildCommentBody(release, rc, prNumber, relativeFilePath, reviewDate)
316+
// Fetch assignees (or fall back to issue author) for the release issue
317+
let assignees: string[] = []
318+
try {
319+
const raw = ghRead(['api', `repos/github/releases/issues/${note.issueNumber}`])
320+
const issue = JSON.parse(raw)
321+
assignees = (issue.assignees || []).map((a: { login: string }) => a.login)
322+
// Fall back to the issue author unless they're a bot
323+
if (assignees.length === 0 && issue.user?.login && issue.user.type !== 'Bot') {
324+
assignees = [issue.user.login]
325+
}
326+
} catch {
327+
// If we can't fetch the issue, post without mentions
328+
}
329+
330+
const commentBody = buildCommentBody(release, rc, prNumber, assignees)
343331

344332
const label = `[${i + 1}/${toNotify.length}] #${note.issueNumber}`
345333

0 commit comments

Comments
 (0)