mirror of https://github.com/certd/certd
chore: 通知优化
parent
a9b302e38d
commit
81282a9c88
|
@ -203,6 +203,7 @@ export class RunnableCollection {
|
||||||
if (runnable?.status) {
|
if (runnable?.status) {
|
||||||
runnable.status.status = ResultType.none;
|
runnable.status.status = ResultType.none;
|
||||||
runnable.status.result = ResultType.none;
|
runnable.status.result = ResultType.none;
|
||||||
|
runnable.status.output = {};
|
||||||
runnable.status.inputHash = "";
|
runnable.status.inputHash = "";
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
runnable.input = {};
|
runnable.input = {};
|
||||||
|
|
|
@ -61,21 +61,23 @@ export class GithubCheckRelease extends AbstractTaskPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
//插件执行方法
|
//插件执行方法
|
||||||
async execute(): Promise<void> {
|
async execute(): Promise<string> {
|
||||||
const access = await this.getAccess<GithubAccess>(this.accessId);
|
const access = await this.getAccess<GithubAccess>(this.accessId);
|
||||||
|
|
||||||
const res = await access.getRelease({repoName:this.repoName})
|
const res = await access.getRelease({repoName:this.repoName})
|
||||||
|
if(res == null){
|
||||||
|
throw new Error(`获取${this.repoName}最新版本失败`)
|
||||||
|
}
|
||||||
const lastVersion = this.ctx.lastStatus?.status?.output?.lastVersion;
|
const lastVersion = this.ctx.lastStatus?.status?.output?.lastVersion;
|
||||||
|
|
||||||
if(res.tag_name == null || res.tag_name ==lastVersion){
|
if(res.tag_name == null || res.tag_name ==lastVersion){
|
||||||
this.logger.info(`暂无更新,${res.tag_name}`);
|
this.logger.info(`暂无更新,${res.tag_name}`);
|
||||||
return
|
return "skip"
|
||||||
}
|
}
|
||||||
//有更新
|
//有更新
|
||||||
this.logger.info(`有更新,${lastVersion}->${res.tag_name}`)
|
this.logger.info(`有更新,${lastVersion??"0"}->${res.tag_name}`)
|
||||||
this.lastVersion = res.tag_name;
|
this.lastVersion = res.tag_name;
|
||||||
|
|
||||||
|
const body = res.body.replaceAll("* ","- ")
|
||||||
//发送通知
|
//发送通知
|
||||||
for (const notificationId of this.notificationIds) {
|
for (const notificationId of this.notificationIds) {
|
||||||
await this.ctx.notificationService.send({
|
await this.ctx.notificationService.send({
|
||||||
|
@ -85,7 +87,7 @@ export class GithubCheckRelease extends AbstractTaskPlugin {
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
body: {
|
body: {
|
||||||
title: `${this.repoName} 新版本 ${this.lastVersion} 发布`,
|
title: `${this.repoName} 新版本 ${this.lastVersion} 发布`,
|
||||||
content: `${res.body}\n\n >Certd:不止证书自动化,插件解锁无限可能!`,
|
content: `${body}\n\n > [Certd](https://certd.docmirror.cn),不止证书自动化,插件解锁无限可能!\n\n`,
|
||||||
url: `https://github.com/${this.repoName}/releases/tag/${this.lastVersion}`,
|
url: `https://github.com/${this.repoName}/releases/tag/${this.lastVersion}`,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -55,14 +55,14 @@ export class QywxNotification extends BaseNotification {
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
|
const color = body.errorMessage?'red':'green';
|
||||||
await this.http.request({
|
await this.http.request({
|
||||||
url: this.webhook,
|
url: this.webhook,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
msgtype: 'text',
|
msgtype: 'markdown',
|
||||||
text: {
|
markdown: {
|
||||||
content: `${body.title}\n${body.content}\n查看详情: ${body.url}`,
|
content: `<font color='${color}'>${body.title}</font>\n\n\n${body.content}\n\n[查看详情](${body.url})`,
|
||||||
mentioned_list: this.mentionedList,
|
mentioned_list: this.mentionedList,
|
||||||
mentioned_mobile_list: this.mentionedMobileList,
|
mentioned_mobile_list: this.mentionedMobileList,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue