GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ci: collect all failed PR merges and notify Discord · romanr/opencode@c9891fe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • script
    • beta.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎script/beta.ts‎

Copy file name to clipboardExpand all lines: script/beta.ts
+57-4Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,42 @@ interface RunResult {
1414
stderr: string
1515
}
1616

17+
interface FailedPR {
18+
number: number
19+
title: string
20+
reason: string
21+
}
22+
23+
async function postToDiscord(failures: FailedPR[]) {
24+
const webhookUrl = process.env.DISCORD_ISSUES_WEBHOOK_URL
25+
if (!webhookUrl) {
26+
console.log("Warning: DISCORD_ISSUES_WEBHOOK_URL not set, skipping Discord notification")
27+
return
28+
}
29+
30+
const message = `**Beta Branch Merge Failures**
31+
32+
The following team PRs failed to merge into the beta branch:
33+
34+
${failures.map((f) => `- **#${f.number}**: ${f.title} - ${f.reason}`).join("\n")}
35+
36+
Please resolve these conflicts manually.`
37+
38+
const content = JSON.stringify({ content: message })
39+
40+
const response = await fetch(webhookUrl, {
41+
method: "POST",
42+
headers: { "Content-Type": "application/json" },
43+
body: content,
44+
})
45+
46+
if (!response.ok) {
47+
console.error("Failed to post to Discord:", await response.text())
48+
} else {
49+
console.log("Posted failures to Discord")
50+
}
51+
}
52+
1753
async function main() {
1854
console.log("Fetching open PRs from team members...")
1955

@@ -52,14 +88,17 @@ async function main() {
5288
}
5389

5490
const applied: number[] = []
91+
const failed: FailedPR[] = []
5592

5693
for (const pr of prs) {
5794
console.log(`\nProcessing PR #${pr.number}: ${pr.title}`)
5895

5996
console.log(" Fetching PR head...")
6097
const fetch = await run(["git", "fetch", "origin", `pull/${pr.number}/head:pr/${pr.number}`])
6198
if (fetch.exitCode !== 0) {
62-
throw new Error(`Failed to fetch PR #${pr.number}: ${fetch.stderr}`)
99+
console.log(` Failed to fetch: ${fetch.stderr}`)
100+
failed.push({ number: pr.number, title: pr.title, reason: "Fetch failed" })
101+
continue
63102
}
64103

65104
console.log(" Merging...")
@@ -69,7 +108,8 @@ async function main() {
69108
await $`git merge --abort`.nothrow()
70109
await $`git checkout -- .`.nothrow()
71110
await $`git clean -fd`.nothrow()
72-
throw new Error(`Failed to merge PR #${pr.number}: Has conflicts`)
111+
failed.push({ number: pr.number, title: pr.title, reason: "Merge conflicts" })
112+
continue
73113
}
74114

75115
const mergeHead = await $`git rev-parse -q --verify MERGE_HEAD`.nothrow()
@@ -80,13 +120,17 @@ async function main() {
80120

81121
const add = await $`git add -A`.nothrow()
82122
if (add.exitCode !== 0) {
83-
throw new Error(`Failed to stage changes for PR #${pr.number}`)
123+
console.log(" Failed to stage changes")
124+
failed.push({ number: pr.number, title: pr.title, reason: "Staging failed" })
125+
continue
84126
}
85127

86128
const commitMsg = `Apply PR #${pr.number}: ${pr.title}`
87129
const commit = await run(["git", "commit", "-m", commitMsg])
88130
if (commit.exitCode !== 0) {
89-
throw new Error(`Failed to commit PR #${pr.number}: ${commit.stderr}`)
131+
console.log(` Failed to commit: ${commit.stderr}`)
132+
failed.push({ number: pr.number, title: pr.title, reason: "Commit failed" })
133+
continue
90134
}
91135

92136
console.log(" Applied successfully")
@@ -97,6 +141,15 @@ async function main() {
97141
console.log(`Applied: ${applied.length} PRs`)
98142
applied.forEach((num) => console.log(` - PR #${num}`))
99143

144+
if (failed.length > 0) {
145+
console.log(`Failed: ${failed.length} PRs`)
146+
failed.forEach((f) => console.log(` - PR #${f.number}: ${f.reason}`))
147+
148+
await postToDiscord(failed)
149+
150+
throw new Error(`${failed.length} PR(s) failed to merge. Check Discord for details.`)
151+
}
152+
100153
console.log("\nForce pushing beta branch...")
101154
const push = await $`git push origin beta --force --no-verify`.nothrow()
102155
if (push.exitCode !== 0) {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.