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,