Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit d35956f

Browse files
committed
ci: prevent rate limit errors when fetching team PRs for beta releases
1 parent 7417e6e commit d35956f

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

script/beta.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/usr/bin/env bun
22

3+
import { Script } from "@opencode-ai/script"
4+
35
interface PR {
46
number: number
57
title: string
8+
author: { login: string }
69
}
710

811
interface RunResult {
@@ -12,15 +15,29 @@ interface RunResult {
1215
}
1316

1417
async function main() {
15-
console.log("Fetching open contributor PRs...")
16-
17-
const prsResult = await $`gh pr list --label contributor --state open --json number,title --limit 100`.nothrow()
18-
if (prsResult.exitCode !== 0) {
19-
throw new Error(`Failed to fetch PRs: ${prsResult.stderr}`)
18+
console.log("Fetching open PRs from team members...")
19+
20+
const allPrs: PR[] = []
21+
for (const member of Script.team) {
22+
const result = await $`gh pr list --state open --author ${member} --json number,title,author --limit 100`.nothrow()
23+
if (result.exitCode !== 0) continue
24+
const memberPrs: PR[] = JSON.parse(result.stdout)
25+
allPrs.push(...memberPrs)
2026
}
2127

22-
const prs: PR[] = JSON.parse(prsResult.stdout)
23-
console.log(`Found ${prs.length} open contributor PRs`)
28+
const seen = new Set<number>()
29+
const prs = allPrs.filter((pr) => {
30+
if (seen.has(pr.number)) return false
31+
seen.add(pr.number)
32+
return true
33+
})
34+
35+
console.log(`Found ${prs.length} open PRs from team members`)
36+
37+
if (prs.length === 0) {
38+
console.log("No team PRs to merge")
39+
return
40+
}
2441

2542
console.log("Fetching latest dev branch...")
2643
const fetchDev = await $`git fetch origin dev`.nothrow()
@@ -35,17 +52,14 @@ async function main() {
3552
}
3653

3754
const applied: number[] = []
38-
const skipped: Array<{ number: number; reason: string }> = []
3955

4056
for (const pr of prs) {
4157
console.log(`\nProcessing PR #${pr.number}: ${pr.title}`)
4258

4359
console.log(" Fetching PR head...")
4460
const fetch = await run(["git", "fetch", "origin", `pull/${pr.number}/head:pr/${pr.number}`])
4561
if (fetch.exitCode !== 0) {
46-
console.log(` Failed to fetch PR head: ${fetch.stderr}`)
47-
skipped.push({ number: pr.number, reason: `Fetch failed: ${fetch.stderr}` })
48-
continue
62+
throw new Error(`Failed to fetch PR #${pr.number}: ${fetch.stderr}`)
4963
}
5064

5165
console.log(" Merging...")
@@ -55,34 +69,24 @@ async function main() {
5569
await $`git merge --abort`.nothrow()
5670
await $`git checkout -- .`.nothrow()
5771
await $`git clean -fd`.nothrow()
58-
skipped.push({ number: pr.number, reason: "Has conflicts" })
59-
continue
72+
throw new Error(`Failed to merge PR #${pr.number}: Has conflicts`)
6073
}
6174

6275
const mergeHead = await $`git rev-parse -q --verify MERGE_HEAD`.nothrow()
6376
if (mergeHead.exitCode !== 0) {
6477
console.log(" No changes, skipping")
65-
skipped.push({ number: pr.number, reason: "No changes" })
6678
continue
6779
}
6880

6981
const add = await $`git add -A`.nothrow()
7082
if (add.exitCode !== 0) {
71-
console.log(" Failed to stage")
72-
await $`git checkout -- .`.nothrow()
73-
await $`git clean -fd`.nothrow()
74-
skipped.push({ number: pr.number, reason: "Failed to stage" })
75-
continue
83+
throw new Error(`Failed to stage changes for PR #${pr.number}`)
7684
}
7785

7886
const commitMsg = `Apply PR #${pr.number}: ${pr.title}`
7987
const commit = await run(["git", "commit", "-m", commitMsg])
8088
if (commit.exitCode !== 0) {
81-
console.log(` Failed to commit: ${commit.stderr}`)
82-
await $`git checkout -- .`.nothrow()
83-
await $`git clean -fd`.nothrow()
84-
skipped.push({ number: pr.number, reason: `Commit failed: ${commit.stderr}` })
85-
continue
89+
throw new Error(`Failed to commit PR #${pr.number}: ${commit.stderr}`)
8690
}
8791

8892
console.log(" Applied successfully")
@@ -92,8 +96,6 @@ async function main() {
9296
console.log("\n--- Summary ---")
9397
console.log(`Applied: ${applied.length} PRs`)
9498
applied.forEach((num) => console.log(` - PR #${num}`))
95-
console.log(`Skipped: ${skipped.length} PRs`)
96-
skipped.forEach((x) => console.log(` - PR #${x.number}: ${x.reason}`))
9799

98100
console.log("\nForce pushing beta branch...")
99101
const push = await $`git push origin beta --force --no-verify`.nothrow()

0 commit comments

Comments
 (0)