const https = require('https'); const packageInfo = require('../package.json'); // 从package.json文件中提取name、版本号 const config = { name: packageInfo.name, version: packageInfo.version, }; // 从文件Changelog.md中获取更新内容 const fs = require("fs"); const buffer = fs.readFileSync('./Changelog.md', "utf-8"); const changelog = buffer.match(/```js\s*((.|\s)*?)\s*```/ig).pop().replace(/```js\s*((.|\s)*?)\s*```/ig, '$1'); const DEPLOYED_MESSAGE = ` ${config.name} ${config.version} 发布成功! 更新内容: ${changelog} 查看链接: http://***/-/web/detail/${config.name} `; const data = { msgtype: 'text', text: { 'content': DEPLOYED_MESSAGE }}; const requestData = JSON.stringify(data); const token = '*******'; // 机器人id const url = 'qyapi.weixin.qq.com'; const req = https.request({ hostname: url, port: 443, path: `/cgi-bin/webhook/send?key=${token}`, method: 'POST', json: true, headers: { 'Content-Type': 'application/json; charset=utf-8' } }); req.write(requestData); req.on('error', function(err) { console.error(err); }); req.end(); console.log('企业微信已通知成功');
javascript 项目部署成功,机器人自动通知企业微信群
最新推荐文章于 2023-09-30 11:23:15 发布