update docker

This commit is contained in:
lxk0301
2021-02-23 11:25:00 +08:00
parent 02f480f513
commit 1123562ba6
2 changed files with 25 additions and 6 deletions

View File

@@ -1,9 +1,23 @@
const notify = require('../sendNotify');
function image_update_notify() {
if (process.env.NOTIFY_CONTENT) {
notify.sendNotify("⚠Docker镜像版本更新通知⚠", process.env.NOTIFY_CONTENT)
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();
!(async() => {
await image_update_notify();
})().catch((e) => console.log(e))