--
:
--
:
--
hugo-teek is loading...
cnb配置机器人2种方式
最后更新于:
背景


https://cnb.cool/w3c/vitepress-theme-teek
1main:
2 push:
3 - runner:
4 cpus: 64
5 docker:
6 image: node:22
7 stages:
8 # 将依赖存起来,下次构建就不需要安装依赖了,每次构建都重复安装依赖就很烦,也很慢.缓存一次供后续循环使用,直到package.json有改动才会在次生成缓存
9 - name: 构建缓存镜像
10 type: docker:cache
11 options:
12 dockerfile: cache.dockerfile
13 # 将以下文件的依赖推送到制品保存起来,循环复用,只有首次和package.json有改动导致依赖有变化才会触发下一次推送制品
14 by:
15 - package.json
16 - pnpm-lock.yaml
17 versionBy:
18 - pnpm-lock.yaml
19 exports:
20 name: DOCKER_CACHE_IMAGE_NAME
21 - name: 使用缓存的node_modules,免安装依赖
22 image: $DOCKER_CACHE_IMAGE_NAME
23 commands:
24 - cp -r "$NODE_PATH" ./node_modules
25 - name: 构建当前项目
26 # 构建时不需要安装依赖的命令了,因为依赖已经在制品里安装过了
27 script: npm install -g pnpm && npm run docs:build
28 # 以下这部分是zip打包,内容多可以用,内容少就没用,因为推送也很快
29 # - name: 使用zip工具
30 # script: apt-get update && apt-get install -y zip
31 # - name: 打包压缩dist内文件
32 # script: |
33 # cd /workspace/.vitepress/dist/
34 # zip -r dist.zip ./*
35 - name: 部署到Pages
36 imports: https://cnb.cool/w3c/envs/-/blob/main/pages.yml
37 script: npx edgeone pages deploy ./.vitepress/dist/ --name vitepress-theme-teek --token $EDGEONE_PAGES_API_TOKEN
38
39 web_trigger:
40 - runner:
41 cpus: 64
42 docker:
43 image: node:22
44 stages:
45 # 将依赖存起来,下次构建就不需要安装依赖了,每次构建都重复安装依赖就很烦,也很慢.缓存一次供后续循环使用,直到package.json有改动才会在次生成缓存
46 - name: 构建缓存镜像
47 type: docker:cache
48 options:
49 dockerfile: cache.dockerfile
50 # 将以下文件的依赖推送到制品保存起来,循环复用,只有首次和package.json有改动导致依赖有变化才会触发下一次推送制品
51 by:
52 - package.json
53 - pnpm-lock.yaml
54 versionBy:
55 - pnpm-lock.yaml
56 exports:
57 name: DOCKER_CACHE_IMAGE_NAME
58 - name: 使用缓存的node_modules,免安装依赖
59 image: $DOCKER_CACHE_IMAGE_NAME
60 commands:
61 - cp -r "$NODE_PATH" ./node_modules
62 - name: 构建当前项目
63 # 构建时不需要安装依赖的命令了,因为依赖已经在制品里安装过了
64 script: npm install -g pnpm && npm run docs:build
65 # 以下这部分是zip打包,内容多可以用,内容少就没用,因为推送也很快
66 # - name: 使用zip工具
67 # script: apt-get update && apt-get install -y zip
68 # - name: 打包压缩dist内文件
69 # script: |
70 # cd /workspace/.vitepress/dist/
71 # zip -r dist.zip ./*
72 - name: 部署到Pages
73 imports: https://cnb.cool/w3c/envs/-/blob/main/pages.yml
74 script: npx edgeone pages deploy ./.vitepress/dist/ --name vitepress-theme-teek --token $EDGEONE_PAGES_API_TOKEN
自己之前.cnb.yml内容(修改前)
1master:
2 push:
3 - runner:
4 cpus: 64
5 services:
6 - docker
7 imports:
8 - https://cnb.cool/onedayxyy/secret/-/blob/main/envs.yml
9 docker:
10 image: docker.cnb.cool/znb/images/node:18
11 stages:
12 - name: set env
13 script: echo -n $(date "+%Y-%m-%d %H:%M")
14 exports:
15 info: CUSTOM_ENV_DATE_INFO
16 - name: 🖨️ 打印环境
17 if: |
18 [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
19 script: |
20 node -v && npm -v && yarn -v && pnpm -v
21 # - name: 🗄️ 声明缓存
22 # cache:
23 # key: ${CNB_BUILD_ID}
24 # paths:
25 # - docs/.vitepress/dist # 缓存构建产物
26 # - node_modules # 可选,加速后续构建
27 - name: 📦️ 安装依赖
28 if: |
29 [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
30 script: |
31 pnpm install
32
33 - name: ⚗️ 编译项目
34 if: |
35 [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
36 script: |
37 pnpm docs:build # VitePress 专用命令
38 ls -la docs/.vitepress/dist # 确认构建文件存在
39 # cd docs/.vitepress/dist
40 # git init
41 # git remote add origin https://cnb.cool/onedayxyy/vitepress-theme-teek-one-public.git
42 # git add -A
43 # git commit -m "Deploying to CNB"
44 # git push -u origin master:dist -f
45
46
47 # - name: 🚀 强制同步到公开仓库
48 # image: alpine/git
49 # cache:
50 # key: ${CNB_BUILD_ID}
51 # paths:
52 # - docs/.vitepress/dist
53 # script: |
54 # # 配置 Git
55 # git config --global user.name "CI-Bot"
56 # git config --global user.email "ci@onedayxyy.cn"
57
58 # # 清理旧目录(防止残留)
59 # rm -rf /tmp/public-repo
60
61 # # 尝试克隆 dist 分支,失败则初始化新分支
62 # if ! git clone -b dist --single-branch \
63 # https://${GIT_USERNAME}:${GIT_ACCESS_TOKEN}@cnb.cool/onedayxyy/vitepress-theme-teek-one-public.git \
64 # /tmp/public-repo 2>/dev/null; then
65
66 # echo "➜ dist 分支不存在,初始化新仓库..."
67 # git clone https://${GIT_USERNAME}:${GIT_ACCESS_TOKEN}@cnb.cool/onedayxyy/vitepress-theme-teek-one-public.git /tmp/public-repo
68 # cd /tmp/public-repo
69 # git checkout --orphan dist
70 # git commit --allow-empty -m "Initial empty dist branch" # 必须有一个提交
71 # fi
72
73 # # 进入目录并清空内容(保留 .git)
74 # cd /tmp/public-repo
75 # echo "➜ 当前目录内容:"
76 # ls -la
77 # find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
78
79 # # 验证源目录存在
80 # echo "➜ 源目录内容:"
81 # ls -la ${CNB_BUILD_ID}
82 # cp -r ${CNB_BUILD_ID} .
83
84 # # 提交并强制推送
85 # git add -A
86 # git status # 调试查看
87 # git commit -m "Update: Auto sync from ${CNB_COMMIT_SHORT}"
88 # git push origin dist --force
89 # echo "✅ 同步完成"
90 # - name: 🚀 同步到公开仓库
91 # if: |
92 # [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
93 # image: tencentcom/git-sync
94 # settings:
95 # branch: dist # 指定目标分支
96 # create_missing_branch: true # 自动创建不存在的分支
97 # auth_type: https
98 # username: ${GIT_cnb_USERNAME} # 从环境变量读取
99 # password: ${GIT_cnb_ACCESS_TOKEN} # 需有目标仓库写入权限
100 # target_url: https://cnb.cool/onedayxyy/vitepress-theme-teek-one-public.git
101 # source_dir: ./docs/.vitepress/dist # 要推送的目录
102 # force: true # 强制覆盖目标分支
103 # git_config: |
104 # user.name "CI-Bot"
105 # user.email "ci@onedayxyy.cn"
106
107 - name: 🚚 部署到Pages
108 if: |
109 [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
110 image: node:22
111 script: npx edgeone pages deploy ./docs/.vitepress/dist --name vitepress-theme-teek-one-private --token $EDGEONE_PAGES_API_TOKEN
112
113 # - name: 🚚 发布制品 (把Teek静态文件从云服务器)
114 # if: |
115 # [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
116 # image: tencentcom/rsync
117 # settings:
118 # user: ${SSH_USER}
119 # key: ${SSH_KEY}
120 # port: 22
121 # hosts:
122 # - ${ECS_IP}
123 # source: docs/.vitepress/dist/
124 # target: /root/rsync/rsync-vitepress/dist/
125 # delete: true
126 # prescript:
127 # - echo "prescript"
128 # - ls -l /root/rsync/rsync-vitepress/dist/
129 # script:
130 # - echo "after script"
131 # - ls -l /root/rsync/rsync-vitepress/dist/
132 # - date
133 # # - bash /root/website_music.sh
134 # - aliyun cdn RefreshObjectCaches --ObjectType File --ObjectPath "onedayxyy.cn/" #刷新阿里云cdn缓存
135
136
137
138 # - name: 🧘♂️ 刷新缓存
139 # image: docker.cnb.cool/znb/cdn-refresh
140 # settings:
141 # ak: "${TENCENT_OPSRE_AK}"
142 # sk: "${TENCENT_OPSRE_SK}"
143 # kind: "tencenteo"
144 # rtype: "path"
145 # domain: "onedayxyy.cn"
146 # urls:
147 # - "https://onedayxyy.cn/"
148
149 #同步仓库到gitee
150 - name: sync to gitee
151 image: tencentcom/git-sync
152 settings:
153 branch: master
154 auth_type: https
155 username: ${GIT_USERNAME}
156 password: ${GIT_ACCESS_TOKEN}
157 target_url: https://gitee.com/onlyonexl/vitepress-theme-teek-one-private.git
158 # git_email: 'github-actions[bot]@users.noreply.github.com'
159
160 - name: 🔔 发布通知
161 image: tencentcom/wecom-message
162 settings:
163 robot: ${WECOM_BOT}
164 msgType: markdown
165 content: |
166 > **🎉 One Blog 又一次发布成功啦!**
167 > **构建时间:** $CUSTOM_ENV_DATE_INFO
168 > **构建id:** $CNB_BUILD_ID
169 > **提交id:** $CNB_COMMIT_SHORT
170 > **构建分支:** $CNB_BRANCH
171 > **提交信息:** $CNB_COMMIT_MESSAGE_TITLE
172 > **提交者:** $CNB_COMMITTER
173 > **仓库地址:** [$CNB_REPO_URL_HTTPS]($CNB_REPO_URL_HTTPS)
174 > **我的网站:** [onedayxyy.cn](https://onedayxyy.cn/)
175
176 - name: build knowledge base
177 image: cnbcool/knowledge-base
178 settings:
179 embedding_model: bge-m3
180 include: "**/**.md"
181 exclude: ""
群里钉钉内容(可以看到构建耗时)
.cnb.yml内容
1main:
2 push:
3 "volume-cache":
4 name: 云原生构建
5 runner:
6 cpus: 64
7 imports:
8 - https://cnb.cool/5566/secret/-/blob/main/envs.yml
9 docker:
10 image: node:22
11 stages:
12 - name: set env
13 script: echo -n $(date +%s)
14 exports:
15 info: CUSTOM_ENV_START_TIME
16 - name: 🏠️ 设置淘宝源
17 script: |
18 npm config set registry https://registry.npmmirror.com
19 - name: 🖨️ 打印环境
20 script: |
21 npm install -g pnpm && node -v && npm -v && yarn -v && pnpm -v
22 - name: 📦️ 安装依赖
23 script: |
24 pnpm install
25 - name: ⚗️ 编译项目
26 script: |
27 pnpm docs:build
28 - name: 🚚 部署到Pages
29 image: node:22
30 script: >-
31 npx edgeone pages deploy ./docs/.vitepress/dist --name
32 ceshi --token $EDGEONE_PAGES_API_TOKEN
33 - name: ⏱️ 计算耗时
34 script: |
35 # 计算耗时
36 end_time=$(date +%s)
37 duration=$((end_time - $CUSTOM_ENV_START_TIME))
38 minutes=$((duration / 60))
39 seconds=$((duration % 60))
40 time_str="${minutes}分${seconds}秒"
41 echo -n ${time_str}
42 exports:
43 info: CUSTOM_ENV_BUILD_TIME
44 - name: 钉钉通知
45 image: tencentcom/dingtalk-bot-msg:latest
46 settings:
47 content: "「KylinOS/UOS技术文档」发布完成,耗时: ${CUSTOM_ENV_BUILD_TIME}"
48 c_type: "text" # 支持: text, markdown, link, actionCard, multiActionCard, feedCard
49 secret: $SECRET
50 webhook: $WEBHOOK
51 isAtAll: false
52 debug: false # 新增: 是否启用调试模式
自己最新内容(修改后)-v1-传统版(测试成功)
1master:
2 push:
3 "volume-cache":
4 name: 云原生构建
5 runner:
6 cpus: 64
7 imports:
8 - https://cnb.cool/onedayxyy/secret/-/blob/main/envs.yml
9 docker:
10 image: node:22
11 stages:
12 - name: set env
13 script: echo -n $(date +%s)
14 exports:
15 info: CUSTOM_ENV_START_TIME
16 - name: 🏠️ 设置淘宝源
17 script: |
18 npm config set registry https://registry.npmmirror.com
19 - name: 🖨️ 打印环境
20 script: |
21 npm install -g pnpm && node -v && npm -v && yarn -v && pnpm -v
22 - name: 📦️ 安装依赖
23 script: |
24 pnpm install
25 - name: ⚗️ 编译项目
26 script: |
27 pnpm docs:build
28 - name: 🚚 部署到Pages
29 image: node:22
30 script: >-
31 npx edgeone pages deploy ./docs/.vitepress/dist --name
32 vitepress-theme-teek-one-private --token $EDGEONE_PAGES_API_TOKEN
33
34
35 #同步仓库到gitee
36 - name: sync to gitee
37 image: tencentcom/git-sync
38 settings:
39 branch: master
40 auth_type: https
41 username: ${GIT_USERNAME}
42 password: ${GIT_ACCESS_TOKEN}
43 target_url: https://gitee.com/onlyonexl/vitepress-theme-teek-one-private.git
44 # git_email: 'github-actions[bot]@users.noreply.github.com'
45
46 # - name: build knowledge base
47 # image: cnbcool/knowledge-base
48 # settings:
49 # embedding_model: bge-m3
50 # include: "**/**.md"
51 # exclude: ""
52
53 - name: ⏱️ 计算耗时
54 script: |
55 # 计算耗时
56 end_time=$(date +%s)
57 duration=$((end_time - $CUSTOM_ENV_START_TIME))
58 minutes=$((duration / 60))
59 seconds=$((duration % 60))
60 time_str="${minutes}分${seconds}秒"
61 echo -n ${time_str}
62 exports:
63 info: CUSTOM_ENV_BUILD_TIME
64
65
66 - name: 钉钉通知
67 image: tencentcom/dingtalk-bot-msg:latest
68 settings:
69 content: "「One Blog」发布完成,耗时: ${CUSTOM_ENV_BUILD_TIME}"
70 c_type: "text" # 支持: text, markdown, link, actionCard, multiActionCard, feedCard
71 secret: $SECRET
72 webhook: $WEBHOOK
73 isAtAll: false
74 debug: false # 新增: 是否启用调试模式
75
76 # - name: 🔔 发布通知
77 # image: tencentcom/wecom-message
78 # settings:
79 # robot: ${WECOM_BOT}
80 # msgType: markdown
81 # content: |
82 # > **🎉 One Blog 又一次发布成功啦!**
83 # > **构建时间:** $CUSTOM_ENV_DATE_INFO
84 # > **构建耗时:** ${CUSTOM_ENV_BUILD_TIME}
85 # > **构建id:** $CNB_BUILD_ID
86 # > **提交id:** $CNB_COMMIT_SHORT
87 # > **构建分支:** $CNB_BRANCH
88 # > **提交信息:** $CNB_COMMIT_MESSAGE_TITLE
89 # > **提交者:** $CNB_COMMITTER
90 # > **仓库地址:** [$CNB_REPO_URL_HTTPS]($CNB_REPO_URL_HTTPS)
91 # > **我的网站:** [onedayxyy.cn](https://onedayxyy.cn/)
自己最新内容(修改后)-v2-制品版(测试成功)
1master:
2 push:
3 - runner:
4 cpus: 64
5 imports:
6 - https://cnb.cool/onedayxyy/secret/-/blob/main/envs.yml
7 docker:
8 image: node:22
9 stages:
10 - name: 😉 set env
11 script: echo -n $(date +%s)
12 exports:
13 info: CUSTOM_ENV_START_TIME
14 # - name: 🖨️ 打印环境
15 # if: |
16 # [ "$CNB_COMMIT_MESSAGE_TITLE" = "BUILD" ]
17 # script: |
18 # node -v && npm -v && yarn -v && pnpm -v
19
20 # 将依赖存起来,下次构建就不需要安装依赖了,每次构建都重复安装依赖就很烦,也很慢.缓存一次供后续循环使用,直到package.json有改动才会在次生成缓存
21 - name: 📢 构建缓存镜像
22 type: docker:cache
23 options:
24 dockerfile: cache.dockerfile
25 # 将以下文件的依赖推送到制品保存起来,循环复用,只有首次和package.json有改动导致依赖有变化才会触发下一次推送制品
26 by:
27 - package.json
28 - pnpm-lock.yaml
29 versionBy:
30 - pnpm-lock.yaml
31 exports:
32 name: DOCKER_CACHE_IMAGE_NAME
33 - name: 📦 使用缓存的node_modules,免安装依赖
34 image: $DOCKER_CACHE_IMAGE_NAME
35 commands:
36 - cp -r "$NODE_PATH" ./node_modules
37 - name: 🔨 构建当前项目
38 # 构建时不需要安装依赖的命令了,因为依赖已经在制品里安装过了
39 script: npm install -g pnpm && npm run docs:build
40 # 以下这部分是zip打包,内容多可以用,内容少就没用,因为推送也很快
41 # - name: 使用zip工具
42 # script: apt-get update && apt-get install -y zip
43 # - name: 打包压缩dist内文件
44 # script: |
45 # cd /workspace/.vitepress/dist/
46 # zip -r dist.zip ./*
47 - name: 🎉部署到Pages
48 script: npx edgeone pages deploy ./docs/.vitepress/dist --name vitepress-theme-teek-one-private --token $EDGEONE_PAGES_API_TOKEN
49
50
51
52 #同步仓库到gitee
53 - name: 📌 sync to gitee
54 image: tencentcom/git-sync
55 settings:
56 branch: master
57 auth_type: https
58 username: ${GIT_USERNAME}
59 password: ${GIT_ACCESS_TOKEN}
60 target_url: https://gitee.com/onlyonexl/vitepress-theme-teek-one-private.git
61 # git_email: 'github-actions[bot]@users.noreply.github.com'
62
63 # - name: 👀 build knowledge base
64 # image: cnbcool/knowledge-base
65 # settings:
66 # embedding_model: bge-m3
67 # include: "**/**.md"
68 # exclude: ""
69
70 - name: ⏱️ 计算耗时
71 script: |
72 # 计算耗时
73 end_time=$(date +%s)
74 duration=$((end_time - $CUSTOM_ENV_START_TIME))
75 minutes=$((duration / 60))
76 seconds=$((duration % 60))
77 time_str="${minutes}分${seconds}秒"
78 echo -n ${time_str}
79 exports:
80 info: CUSTOM_ENV_BUILD_TIME
81
82 - name: 钉钉通知
83 image: tencentcom/dingtalk-bot-msg:latest
84 settings:
85 content: "「One Blog」发布完成,耗时: ${CUSTOM_ENV_BUILD_TIME}"
86 c_type: "text" # 支持: text, markdown, link, actionCard, multiActionCard, feedCard
87 secret: $SECRET
88 webhook: $WEBHOOK
89 isAtAll: false
90 debug: false # 新增: 是否启用调试模式
91
92 # - name: 🔔 发布通知
93 # image: tencentcom/wecom-message
94 # settings:
95 # robot: ${WECOM_BOT}
96 # msgType: markdown
97 # content: |
98 # > **🎉 One Blog 又一次发布成功啦!**
99 # > **构建时间:** $CUSTOM_ENV_DATE_INFO
100 # > **构建id:** $CNB_BUILD_ID
101 # > **提交id:** $CNB_COMMIT_SHORT
102 # > **构建分支:** $CNB_BRANCH
103 # > **提交信息:** $CNB_COMMIT_MESSAGE_TITLE
104 # > **提交者:** $CNB_COMMITTER
105 # > **仓库地址:** [$CNB_REPO_URL_HTTPS]($CNB_REPO_URL_HTTPS)
106 # > **我的网站:** [onedayxyy.cn](https://onedayxyy.cn/)
效果:耗时5min46s


部署到pages还是耗时
dist目录压缩包超过25M,就没法通过cnb传输到eo pages里去。



警告
要想解决这个问题,只能等群主把teek的404问题解决才行。
📡
👤
作者:
余温Gueen
🌐
版权:
本站文章除特别声明外,均采用
CC BY-NC-SA 4.0
协议,转载请注明来自
余温Gueen Blog!
推荐使用微信支付

推荐使用支付宝
