Skip to content

Commit 80cf2fe

Browse files
authored
fix(release): Improve Patch Release Workflow Comments: Clearer Approval Guidance (#21894)
1 parent 0b78de9 commit 80cf2fe

5 files changed

Lines changed: 77 additions & 46 deletions

File tree

.github/workflows/release-patch-0-from-comment.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ jobs:
120120
if (recentRuns.length > 0) {
121121
core.setOutput('dispatched_run_urls', recentRuns.map(r => r.html_url).join(','));
122122
core.setOutput('dispatched_run_ids', recentRuns.map(r => r.id).join(','));
123+
124+
const markdownLinks = recentRuns.map(r => `- [View dispatched workflow run](${r.html_url})`).join('\n');
125+
core.setOutput('dispatched_run_links', markdownLinks);
123126
}
124127
125128
- name: 'Comment on Failure'
@@ -138,16 +141,19 @@ jobs:
138141
token: '${{ secrets.GITHUB_TOKEN }}'
139142
issue-number: '${{ github.event.issue.number }}'
140143
body: |
141-
**Patch workflow(s) dispatched successfully!**
144+
🚀 **[Step 1/4] Patch workflow(s) waiting for approval!**
142145
143146
**📋 Details:**
144147
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
145148
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
146149
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
147150
151+
**⏳ Status:** The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the specific workflow links below and approve the runs.
152+
148153
**🔗 Track Progress:**
149-
- [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
150-
- [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
154+
${{ steps.dispatch_patch.outputs.dispatched_run_links }}
155+
- [View patch workflow history](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
156+
- [This trigger workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
151157
152158
- name: 'Final Status Comment - Dispatch Success (No URL)'
153159
if: "always() && startsWith(github.event.comment.body, '/patch') && steps.dispatch_patch.outcome == 'success' && !steps.dispatch_patch.outputs.dispatched_run_urls"
@@ -156,16 +162,18 @@ jobs:
156162
token: '${{ secrets.GITHUB_TOKEN }}'
157163
issue-number: '${{ github.event.issue.number }}'
158164
body: |
159-
**Patch workflow(s) dispatched successfully!**
165+
🚀 **[Step 1/4] Patch workflow(s) waiting for approval!**
160166
161167
**📋 Details:**
162168
- **Channels**: `${{ steps.dispatch_patch.outputs.dispatched_channels }}`
163169
- **Commit**: `${{ steps.pr_status.outputs.MERGE_COMMIT_SHA }}`
164170
- **Workflows Created**: ${{ steps.dispatch_patch.outputs.dispatched_run_count }}
165171
172+
**⏳ Status:** The patch creation workflow has been triggered and is waiting for deployment approval. Please visit the workflow history link below and approve the runs.
173+
166174
**🔗 Track Progress:**
167-
- [View patch workflows](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
168-
- [This workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
175+
- [View patch workflow history](https://github.com/${{ github.repository }}/actions/workflows/release-patch-1-create-pr.yml)
176+
- [This trigger workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
169177
170178
- name: 'Final Status Comment - Failure'
171179
if: "always() && startsWith(github.event.comment.body, '/patch') && (steps.dispatch_patch.outcome == 'failure' || steps.dispatch_patch.outcome == 'cancelled')"
@@ -174,7 +182,7 @@ jobs:
174182
token: '${{ secrets.GITHUB_TOKEN }}'
175183
issue-number: '${{ github.event.issue.number }}'
176184
body: |
177-
❌ **Patch workflow dispatch failed!**
185+
❌ **[Step 1/4] Patch workflow dispatch failed!**
178186
179187
There was an error dispatching the patch creation workflow.
180188

scripts/releasing/patch-comment.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async function main() {
128128
let commentBody;
129129

130130
if (success) {
131-
commentBody = `✅ **Patch Release Complete!**
131+
commentBody = `✅ **[Step 4/4] Patch Release Complete!**
132132
133133
**📦 Release Details:**
134134
- **Version**: [\`${releaseVersion}\`](https://github.com/${repo.owner}/${repo.repo}/releases/tag/${releaseTag})
@@ -144,9 +144,10 @@ async function main() {
144144
145145
**🔗 Links:**
146146
- [GitHub Release](https://github.com/${repo.owner}/${repo.repo}/releases/tag/${releaseTag})
147-
- [Workflow Run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})`;
147+
- [This release workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
148+
- [Workflow History](https://github.com/${repo.owner}/${repo.repo}/actions/workflows/release-patch-3-release.yml)`;
148149
} else if (raceConditionFailure) {
149-
commentBody = `⚠️ **Patch Release Cancelled - Concurrent Release Detected**
150+
commentBody = `⚠️ **[Step 4/4] Patch Release Cancelled - Concurrent Release Detected**
150151
151152
**🚦 What Happened:**
152153
Another patch release completed while this one was in progress, causing a version conflict.
@@ -163,7 +164,7 @@ Another patch release completed while this one was in progress, causing a versio
163164
- **Next patch should be**: \`${currentReleaseVersion}\`
164165
- **New release tag**: \`${currentReleaseTag || 'unknown'}\``
165166
: `
166-
- **Status**: Version information updated since this release started`
167+
- **Status**: Version information updated since this release was triggered`
167168
}
168169
169170
**🔄 Next Steps:**
@@ -175,9 +176,10 @@ Another patch release completed while this one was in progress, causing a versio
175176
Multiple patch releases can't run simultaneously. When they do, the second one is automatically cancelled to maintain version consistency.
176177
177178
**🔗 Details:**
178-
- [View cancelled workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})`;
179+
- [This release workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
180+
- [Workflow History](https://github.com/${repo.owner}/${repo.repo}/actions/workflows/release-patch-3-release.yml)`;
179181
} else {
180-
commentBody = `❌ **Patch Release Failed!**
182+
commentBody = `❌ **[Step 4/4] Patch Release Failed!**
181183
182184
**📋 Details:**
183185
- **Version**: \`${releaseVersion || 'Unknown'}\`
@@ -190,8 +192,9 @@ Multiple patch releases can't run simultaneously. When they do, the second one i
190192
3. You may need to retry the patch once the issue is resolved
191193
192194
**🔗 Troubleshooting:**
193-
- [View workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
194-
- [View workflow logs](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})`;
195+
- [This release workflow run](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
196+
- [View workflow logs](https://github.com/${repo.owner}/${repo.repo}/actions/runs/${runId})
197+
- [Workflow History](https://github.com/${repo.owner}/${repo.repo}/actions/workflows/release-patch-3-release.yml)`;
195198
}
196199

197200
if (testMode) {

scripts/releasing/patch-create-comment.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function main() {
145145
manualCommands = manualCommandsMatch[1].trim();
146146
}
147147

148-
commentBody = `🔒 **GitHub App Permission Issue**
148+
commentBody = `🔒 **[Step 2/4] GitHub App Permission Issue**
149149
150150
The patch creation failed due to insufficient GitHub App permissions for creating workflow files.
151151
@@ -169,7 +169,7 @@ After running these commands, you can re-run the patch workflow.`
169169
const prMatch = logContent.match(/Found existing PR #(\d+): (.*)/);
170170
if (prMatch) {
171171
const [, prNumber, prUrl] = prMatch;
172-
commentBody = `ℹ️ **Patch PR already exists!**
172+
commentBody = `ℹ️ **[Step 2/4] Patch PR already exists!**
173173
174174
A patch PR for this change already exists: [#${prNumber}](${prUrl}).
175175
@@ -185,7 +185,7 @@ A patch PR for this change already exists: [#${prNumber}](${prUrl}).
185185
const branchMatch = logContent.match(/Hotfix branch (.*) already exists/);
186186
if (branchMatch) {
187187
const [, branch] = branchMatch;
188-
commentBody = `ℹ️ **Patch branch exists but no PR found!**
188+
commentBody = `ℹ️ **[Step 2/4] Patch branch exists but no PR found!**
189189
190190
A patch branch [\`${branch}\`](https://github.com/${repository}/tree/${branch}) exists but has no open PR.
191191
@@ -213,7 +213,7 @@ A patch branch [\`${branch}\`](https://github.com/${repository}/tree/${branch})
213213
logContent.includes('Cherry-pick has conflicts') ||
214214
logContent.includes('[CONFLICTS]');
215215

216-
commentBody = `🚀 **Patch PR Created!**
216+
commentBody = `🚀 **[Step 2/4] Patch PR Created!**
217217
218218
**📋 Patch Details:**
219219
- **Environment**: \`${environment}\`
@@ -228,7 +228,8 @@ ${hasConflicts ? '3' : '2'}. Once merged, the patch release will automatically t
228228
${hasConflicts ? '4' : '3'}. You'll receive updates here when the release completes
229229
230230
**🔗 Track Progress:**
231-
- [View hotfix PR #${mockPrNumber}](${mockPrUrl})`;
231+
- [View hotfix PR #${mockPrNumber}](${mockPrUrl})
232+
- [This patch creation workflow run](https://github.com/${repository}/actions/runs/${runId})`;
232233
} else if (hasGitHubCli) {
233234
// Find the actual PR for the new branch using gh CLI
234235
try {
@@ -269,7 +270,7 @@ ${hasConflicts ? '4' : '3'}. You'll receive updates here when the release comple
269270
logContent.includes('Cherry-pick has conflicts') ||
270271
pr.title.includes('[CONFLICTS]');
271272

272-
commentBody = `🚀 **Patch PR Created!**
273+
commentBody = `🚀 **[Step 2/4] Patch PR Created!**
273274
274275
**📋 Patch Details:**
275276
- **Environment**: \`${environment}\`
@@ -284,10 +285,11 @@ ${hasConflicts ? '3' : '2'}. Once merged, the patch release will automatically t
284285
${hasConflicts ? '4' : '3'}. You'll receive updates here when the release completes
285286
286287
**🔗 Track Progress:**
287-
- [View hotfix PR #${pr.number}](${pr.url})`;
288+
- [View hotfix PR #${pr.number}](${pr.url})
289+
- [This patch creation workflow run](https://github.com/${repository}/actions/runs/${runId})`;
288290
} else {
289291
// Fallback if PR not found yet
290-
commentBody = `🚀 **Patch PR Created!**
292+
commentBody = `🚀 **[Step 2/4] Patch PR Created!**
291293
292294
The patch release PR for this change has been created on branch [\`${branch}\`](https://github.com/${repository}/tree/${branch}).
293295
@@ -296,23 +298,25 @@ The patch release PR for this change has been created on branch [\`${branch}\`](
296298
2. Once merged, the patch release will automatically trigger
297299
298300
**🔗 Links:**
299-
- [View all patch PRs](https://github.com/${repository}/pulls?q=is%3Apr+is%3Aopen+label%3Apatch)`;
301+
- [View all patch PRs](https://github.com/${repository}/pulls?q=is%3Apr+is%3Aopen+label%3Apatch)
302+
- [This patch creation workflow run](https://github.com/${repository}/actions/runs/${runId})`;
300303
}
301304
} catch (error) {
302305
console.log('Error finding PR for branch:', error.message);
303306
// Fallback
304-
commentBody = `🚀 **Patch PR Created!**
307+
commentBody = `🚀 **[Step 2/4] Patch PR Created!**
305308
306309
The patch release PR for this change has been created.
307310
308311
**🔗 Links:**
309-
- [View all patch PRs](https://github.com/${repository}/pulls?q=is%3Apr+is%3Aopen+label%3Apatch)`;
312+
- [View all patch PRs](https://github.com/${repository}/pulls?q=is%3Apr+is%3Aopen+label%3Apatch)
313+
- [This patch creation workflow run](https://github.com/${repository}/actions/runs/${runId})`;
310314
}
311315
}
312316
}
313317
} else {
314318
// Failure
315-
commentBody = `❌ **Patch creation failed!**
319+
commentBody = `❌ **[Step 2/4] Patch creation failed!**
316320
317321
There was an error creating the patch release.
318322
@@ -326,7 +330,7 @@ There was an error creating the patch release.
326330
}
327331

328332
if (!commentBody) {
329-
commentBody = `❌ **Patch creation failed!**
333+
commentBody = `❌ **[Step 2/4] Patch creation failed!**
330334
331335
No output was generated during patch creation.
332336

scripts/releasing/patch-trigger.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ async function main() {
115115
const isDryRun = argv.dryRun || body.includes('[DRY RUN]');
116116
const forceSkipTests =
117117
argv.forceSkipTests || process.env.FORCE_SKIP_TESTS === 'true';
118+
const runId = process.env.GITHUB_RUN_ID || '0';
118119

119120
if (!headRef) {
120121
throw new Error(
@@ -264,7 +265,7 @@ async function main() {
264265
console.log(`Commenting on original PR ${originalPr}...`);
265266
const npmTag = channel === 'stable' ? 'latest' : 'preview';
266267

267-
const commentBody = `🚀 **Patch Release Started!**
268+
const commentBody = `🚀 **[Step 3/4] Patch Release ${environment === 'prod' ? 'Waiting for Approval' : 'Triggered'}!**
268269
269270
**📋 Release Details:**
270271
- **Environment**: \`${environment}\`
@@ -273,10 +274,11 @@ async function main() {
273274
- **Hotfix PR**: Merged ✅
274275
- **Release Branch**: [\`${releaseRef}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${releaseRef})
275276
276-
**⏳ Status:** The patch release is now running. You'll receive another update when it completes.
277+
**⏳ Status:** The patch release has been triggered${environment === 'prod' ? ' and is waiting for deployment approval. Please visit the specific workflow run link below and approve the deployment' : ''}. You'll receive another update when it completes.
277278
278279
**🔗 Track Progress:**
279-
- [View release workflow](https://github.com/${context.repo.owner}/${context.repo.repo}/actions)`;
280+
- [View release workflow history](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/workflows/${workflowId})
281+
- [This trigger workflow run](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId})`;
280282

281283
if (!testMode) {
282284
let tempDir;

0 commit comments

Comments
 (0)