@@ -15,33 +15,18 @@ interface FailedPR { |
15 | 15 | reason: string |
16 | 16 | } |
17 | 17 |
|
18 | | -async function postToDiscord(failures: FailedPR[]) { |
19 | | - const webhookUrl = process.env.DISCORD_ISSUES_WEBHOOK_URL |
20 | | - if (!webhookUrl) { |
21 | | - console.log("Warning: DISCORD_ISSUES_WEBHOOK_URL not set, skipping Discord notification") |
22 | | - return |
23 | | - } |
24 | | - |
25 | | - const message = `**Beta Branch Merge Failures** |
26 | | -
|
27 | | -The following team PRs failed to merge into the beta branch: |
28 | | -
|
29 | | -${failures.map((f) => `- **#${f.number}**: ${f.title} - ${f.reason}`).join("\n")} |
| 18 | +async function commentOnPR(prNumber: number, reason: string) { |
| 19 | + const body = `⚠️ **Blocking Beta Release** |
30 | 20 |
|
31 | | -Please resolve these conflicts manually.` |
| 21 | +This PR cannot be merged into the beta branch due to: **${reason}** |
32 | 22 |
|
33 | | - const content = JSON.stringify({ content: message }) |
| 23 | +Please resolve this issue to include this PR in the next beta release.` |
34 | 24 |
|
35 | | - const response = await fetch(webhookUrl, { |
36 | | - method: "POST", |
37 | | - headers: { "Content-Type": "application/json" }, |
38 | | - body: content, |
39 | | - }) |
40 | | - |
41 | | - if (!response.ok) { |
42 | | - console.error("Failed to post to Discord:", await response.text()) |
43 | | - } else { |
44 | | - console.log("Posted failures to Discord") |
| 25 | + try { |
| 26 | + await $`gh pr comment ${prNumber} --body ${body}` |
| 27 | + console.log(` Posted comment on PR #${prNumber}`) |
| 28 | + } catch (err) { |
| 29 | + console.log(` Failed to post comment on PR #${prNumber}: ${err}`) |
45 | 30 | } |
46 | 31 | } |
47 | 32 |
|
@@ -91,6 +76,7 @@ async function main() { |
91 | 76 | } catch (err) { |
92 | 77 | console.log(` Failed to fetch: ${err}`) |
93 | 78 | failed.push({ number: pr.number, title: pr.title, reason: "Fetch failed" }) |
| 79 | + await commentOnPR(pr.number, "Fetch failed") |
94 | 80 | continue |
95 | 81 | } |
96 | 82 |
|
@@ -109,6 +95,7 @@ async function main() { |
109 | 95 | await $`git clean -fd` |
110 | 96 | } catch {} |
111 | 97 | failed.push({ number: pr.number, title: pr.title, reason: "Merge conflicts" }) |
| 98 | + await commentOnPR(pr.number, "Merge conflicts with dev branch") |
112 | 99 | continue |
113 | 100 | } |
114 | 101 |
|
@@ -124,6 +111,7 @@ async function main() { |
124 | 111 | } catch { |
125 | 112 | console.log(" Failed to stage changes") |
126 | 113 | failed.push({ number: pr.number, title: pr.title, reason: "Staging failed" }) |
| 114 | + await commentOnPR(pr.number, "Failed to stage changes") |
127 | 115 | continue |
128 | 116 | } |
129 | 117 |
|
@@ -133,6 +121,7 @@ async function main() { |
133 | 121 | } catch (err) { |
134 | 122 | console.log(` Failed to commit: ${err}`) |
135 | 123 | failed.push({ number: pr.number, title: pr.title, reason: "Commit failed" }) |
| 124 | + await commentOnPR(pr.number, "Failed to commit changes") |
136 | 125 | continue |
137 | 126 | } |
138 | 127 |
|
@@ -147,10 +136,7 @@ async function main() { |
147 | 136 | if (failed.length > 0) { |
148 | 137 | console.log(`Failed: ${failed.length} PRs`) |
149 | 138 | failed.forEach((f) => console.log(` - PR #${f.number}: ${f.reason}`)) |
150 | | - |
151 | | - await postToDiscord(failed) |
152 | | - |
153 | | - throw new Error(`${failed.length} PR(s) failed to merge. Check Discord for details.`) |
| 139 | + throw new Error(`${failed.length} PR(s) failed to merge`) |
154 | 140 | } |
155 | 141 |
|
156 | 142 | console.log("\nForce pushing beta branch...") |
|