From 8e5bef409ddb8f3fc3a72ebdd44262a6e44968c1 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Mon, 1 Jun 2026 23:58:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=9C=A8=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=B9=B6=E5=88=9B=E5=BB=BA=E7=BC=BA=E5=A4=B1=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cnb.yml | 2 +- src/routes/sync.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.cnb.yml b/.cnb.yml index 7f13265..604912a 100644 --- a/.cnb.yml +++ b/.cnb.yml @@ -12,7 +12,7 @@ script: | bun i bun run src/cli.ts repo sync - timeout: 120s + timeout: 180s main: "crontab: 0 11,23 * * *": !reference [.crontab-job] diff --git a/src/routes/sync.ts b/src/routes/sync.ts index 35400a1..70dd41e 100644 --- a/src/routes/sync.ts +++ b/src/routes/sync.ts @@ -28,6 +28,14 @@ app.route({ if (giteaRepo.code === 200) { // 已经存在了 } else { + // 确保 org 存在,不存在则创建 + const orgRes = await gitea.org.getOrg(org); + if (orgRes.code !== 200) { + await gitea.org.createOrg({ + username: org, + description: `Auto created org for ${org}`, + }).catch(err => console.error(`创建组织 ${org} 失败,可能不是管理员`, err)); + } await gitea.repo.createRepo({ name: org + '/' + repo, description: item.description,