From bad3504d4a15e6989b967b66aa9da8c6981f25bf Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 10 Jun 2025 12:13:04 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20github=20=E7=89=88=E6=9C=AC=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E6=94=AF=E6=8C=81=E6=89=A7=E8=A1=8C=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/plugin-check-release.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/packages/ui/certd-server/src/plugins/plugin-github/plugins/plugin-check-release.ts b/packages/ui/certd-server/src/plugins/plugin-github/plugins/plugin-check-release.ts index 8833f6b4..2a596e84 100644 --- a/packages/ui/certd-server/src/plugins/plugin-github/plugins/plugin-check-release.ts +++ b/packages/ui/certd-server/src/plugins/plugin-github/plugins/plugin-check-release.ts @@ -1,5 +1,6 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskOutput } from "@certd/pipeline"; import { GithubAccess } from "../access.js"; +import {SshClient} from "@certd/plugin-lib"; @IsTaskPlugin({ //命名规范,插件类型+功能(就是目录plugin-demo中的demo),大写字母开头,驼峰命名 @@ -56,6 +57,31 @@ export class GithubCheckRelease extends AbstractTaskPlugin { lastVersion?: string; + @TaskInput({ + title: '主机登录配置', + helper: '登录', + component: { + name: 'access-selector', + type: 'ssh', + }, + required: false, + }) + sshAccessId!: string; + + @TaskInput({ + title: 'shell脚本命令', + component: { + name: 'a-textarea', + vModel: 'value', + rows: 6, + placeholder: `#拉取最新版镜像\ndocker pull greper/certd:latest \n#重建容器 \nnohup sh -c 'sleep 10; cd ~/deploy/certd/ ; docker compose down; docker compose up -d' >/dev/null & `, + }, + helper: '有新版本后执行命令,比如:拉取最新版镜像,然后重建容器\n注意:自己升级自己需要使用nobup配合sleep', + required: false, + }) + script!: string; + + //插件实例化时执行的方法 async onInstance() { } @@ -100,6 +126,19 @@ export class GithubCheckRelease extends AbstractTaskPlugin { }) } + if (this.script != null && this.script.trim() != "") { + const connectConf = await this.getAccess(this.sshAccessId); + const sshClient = new SshClient(this.logger); + const scripts = this.script.split('\n'); + await sshClient.exec({ + connectConf, + script: scripts, + env: { + REPO: this.repoName, + LAST_VERSION: this.lastVersion, + } + }); + } }