From 8d524a2e762f9b19cae5cf0ed72389f1643f4428 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Tue, 23 Feb 2021 12:06:14 +0800 Subject: [PATCH] Revert "update docker" This reverts commit ec975fde --- docker/notify_docker_user.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/docker/notify_docker_user.js b/docker/notify_docker_user.js index 48b33362..4249d533 100644 --- a/docker/notify_docker_user.js +++ b/docker/notify_docker_user.js @@ -1,7 +1,23 @@ const notify = require('../sendNotify'); - -function image_update_notify() { - notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTEXT) +const fs = require('fs'); +const notifyPath = '/scripts/logs/notify.txt'; +async function image_update_notify() { + if (fs.existsSync(notifyPath)) { + //notify.txt文件存在 + const content = await fs.readFileSync(`${notifyPath}`, 'utf8');//读取notify.txt内容 + if (!content.match(process.env.NOTIFY_CONTENT) && process.env.NOTIFY_CONTENT) { + await notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT); + //把通知内容写入notify.txt文件 + await fs.writeFileSync(`${notifyPath}`, JSON.stringify(process.env.NOTIFY_CONTENT)); + } + } else { + if (process.env.NOTIFY_CONTENT) { + notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT) + //把通知内容写入notify.txt文件 + await fs.writeFileSync(`${notifyPath}`, JSON.stringify(process.env.NOTIFY_CONTENT)); + } + } } - -image_update_notify(); \ No newline at end of file +!(async() => { + await image_update_notify(); +})().catch((e) => console.log(e)) \ No newline at end of file