确保在同步仓库数据时,检查并创建缺失的组织

This commit is contained in:
2026-06-01 23:58:50 +08:00
parent b0df0c14b1
commit 8e5bef409d
2 changed files with 9 additions and 1 deletions

View File

@@ -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]

View File

@@ -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,