feat: add updateRepoInfo method to Repo class and implement build configuration

- Introduced `updateRepoInfo` method in the `Repo` class to allow updating repository information such as description, license, site, and topics.
- Updated test cases to demonstrate the usage of the new `updateRepoInfo` method.
- Modified build script to include a configuration for triggering builds with specific events and environment variables.
- Commented out previous repository list fetching code in tests for clarity.
This commit is contained in:
xiongxiao
2026-02-09 00:26:54 +08:00
committed by cnb
parent 183c0d5b77
commit 02a4b86338
5 changed files with 627 additions and 43 deletions

View File

@@ -5,7 +5,7 @@ import { token, showMore, cookie } from "./common.ts";
const repo = new Build({ token: token, cookie: cookie });
const main = async () => {
const build = await repo.startBuild('cnb', {
const build = await repo.startBuild('kevisual/cnb', {
branch: 'main',
env: {
},
@@ -15,4 +15,49 @@ const main = async () => {
console.log("build", build);
}
// main()
// main()
const buildByConfig = async () => {
const build = await repo.startBuild('kevisual/cnb', {
branch: 'main',
env: {
},
event: 'api_trigger_sync_to_gitea',
config: config,
});
console.log("build", showMore(build));
}
const config = `
# .cnb.yml
include:
- https://cnb.cool/kevisual/cnb/-/blob/main/.cnb/template.yml
.common_env: &common_env
env:
TO_REPO: kevisual/cnb
TO_URL: git.xiongxiao.me
imports:
- https://cnb.cool/kevisual/env/-/blob/main/.env.development
.common_sync_to_gitea: &common_sync_to_gitea
- <<: *common_env
services: !reference [.common_sync_to_gitea_template, services]
stages: !reference [.common_sync_to_gitea_template, stages]
.common_sync_from_gitea: &common_sync_from_gitea
- <<: *common_env
services: !reference [.common_sync_from_gitea_template, services]
stages: !reference [.common_sync_from_gitea_template, stages]
main:
web_trigger_sync_to_gitea:
- <<: *common_sync_to_gitea
web_trigger_sync_from_gitea:
- <<: *common_sync_from_gitea
api_trigger_sync_to_gitea:
- <<: *common_sync_to_gitea
api_trigger_sync_from_gitea:
- <<: *common_sync_from_gitea
`
buildByConfig()

View File

@@ -5,9 +5,19 @@ import { token, showMore, cookie } from "./common.ts";
const repo = new Repo({ token: token, cookie: cookie });
const listRes = await repo.getRepoList({
page: 1, page_size: 999, role: 'developer',
flags: 'KnowledgeBase'
});
// const listRes = await repo.getRepoList({
// page: 1, page_size: 999, role: 'developer',
// flags: 'KnowledgeBase'
// });
console.log("listRes", showMore(listRes), listRes.data?.length);
// console.log("listRes", showMore(listRes), listRes.data?.length);
const updateRepo = async () => {
const res = await repo.updateRepoInfo('kevisual/cnb', {
description: 'cnb 的 opencode 和 rest 的 api 进行封装和使用',
topics: ['cnb', 'api']
});
console.log("updateRepo", showMore(res));
}
updateRepo();