2020-12-11 14:47:13 +08:00
|
|
|
|
const notify = require('../sendNotify');
|
2021-02-23 11:25:00 +08:00
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
const notifyPath = '/scripts/logs/notify.txt';
|
|
|
|
|
|
async function image_update_notify() {
|
2021-02-23 11:45:32 +08:00
|
|
|
|
console.log(`文件是否存在${fs.existsSync('/scripts/logs/notify.txt')}`)
|
2021-02-23 11:25:00 +08:00
|
|
|
|
if (fs.existsSync(notifyPath)) {
|
|
|
|
|
|
//notify.txt文件存在
|
|
|
|
|
|
const content = await fs.readFileSync(`${notifyPath}`, 'utf8');//读取notify.txt内容
|
2021-02-23 11:45:32 +08:00
|
|
|
|
console.log(`/scripts/logs/notify.txt里面内容content${content}\n`)
|
|
|
|
|
|
console.log(`环境变量的内容${process.env.NOTIFY_CONTENT}\n`)
|
|
|
|
|
|
console.log(`匹配结果${JSON.stringify(content.match(/process.env.NOTIFY_CONTENT/g))}\n`)
|
2021-02-23 11:25:00 +08:00
|
|
|
|
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 {
|
2020-12-11 15:34:22 +08:00
|
|
|
|
if (process.env.NOTIFY_CONTENT) {
|
2021-02-23 11:25:00 +08:00
|
|
|
|
notify.sendNotify("⚠️Docker镜像版本更新通知⚠️", process.env.NOTIFY_CONTENT)
|
|
|
|
|
|
//把通知内容写入notify.txt文件
|
|
|
|
|
|
await fs.writeFileSync(`${notifyPath}`, JSON.stringify(process.env.NOTIFY_CONTENT));
|
2020-12-11 15:34:22 +08:00
|
|
|
|
}
|
2021-02-23 11:25:00 +08:00
|
|
|
|
}
|
2020-12-11 14:47:13 +08:00
|
|
|
|
}
|
2021-02-23 11:25:00 +08:00
|
|
|
|
!(async() => {
|
|
|
|
|
|
await image_update_notify();
|
|
|
|
|
|
})().catch((e) => console.log(e))
|