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:
@@ -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()
|
||||
20
test/repo.ts
20
test/repo.ts
@@ -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();
|
||||
Reference in New Issue
Block a user