diff --git a/.github/workflows/auto.yml b/.github/workflows/auto.yml index 288b7067..e4f9ca54 100644 --- a/.github/workflows/auto.yml +++ b/.github/workflows/auto.yml @@ -17,6 +17,7 @@ env: DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }} PUSHPLUS_TOKEN: ${{ secrets.PUSHPLUS_TOKEN }} WEIXIN_WEBHOOK: ${{ secrets.WEIXIN_WEBHOOK }} + SERVERPUSHKEY: ${{ secrets.SERVERPUSHKEY }} jobs: CheckIn: diff --git a/README.md b/README.md index 6ad429b9..22505a90 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ | EMAIL_TO | 订阅人邮箱地址(收件人). 如需多人订阅使用 `, ` 分割, 例如: `a@163.com, b@qq.com` | 否 | | DINGDING_WEBHOOK | 钉钉机器人WEBHOOK | 否 | | PUSHPLUS_TOKEN | [Pushplus](http://www.pushplus.plus/) 官网申请,支持微信消息推送 | 否 | + | SERVERPUSHKEY | [Server酱](https://sct.ftqq.com//) 官网申请,支持微信消息推送 | 否 | | WEIXIN_WEBHOOK | 企业微信机器人WEBHOOK | 否 | 4. 仓库 -> Actions, 检查Workflows并启用。 diff --git a/workflows/checkin.js b/workflows/checkin.js index 19e15993..ffcd6e00 100644 --- a/workflows/checkin.js +++ b/workflows/checkin.js @@ -262,6 +262,8 @@ class CheckIn { await this.bugfixTask.run(); await juejin.logout(); console.log("-------------------------"); + + return this.growthTask.todayStatus } toString() { diff --git a/workflows/utils/env.js b/workflows/utils/env.js index 8e9b1c12..4665ebcc 100644 --- a/workflows/utils/env.js +++ b/workflows/utils/env.js @@ -29,5 +29,10 @@ module.exports = { * 企业微信机器人配置 * https://developer.work.weixin.qq.com/document/path/91770 */ - WEIXIN_WEBHOOK: env.WEIXIN_WEBHOOK + WEIXIN_WEBHOOK: env.WEIXIN_WEBHOOK, + /** + * server酱推送key + * https://sct.ftqq.com/sendkey + */ + SERVERPUSHKEY: env.SERVERPUSHKEY, }; diff --git a/workflows/utils/notification-kit.ts b/workflows/utils/notification-kit.ts index 6af4543d..24c58800 100644 --- a/workflows/utils/notification-kit.ts +++ b/workflows/utils/notification-kit.ts @@ -132,6 +132,29 @@ export class NotificationKit { }); } + /** + * serverPush推送 + * @param options + */ + async serverPush(options: PushPlusOptions) { + const token: string | unknown = env.SERVERPUSHKEY; + if (!token || token === "") { + throw new Error("未配置Server酱 key。"); + } + + const config = { + title: options.title, + desp: options.content, + channel: "9", + }; + + return axios.post(`https://sctapi.ftqq.com/${token}.send`, config, { + headers: { + "Content-Type": "application/json" + } + }); + } + /** * 钉钉Webhook * @param options @@ -206,6 +229,7 @@ export class NotificationKit { await trycatch("钉钉", this.dingtalkWebhook.bind(this)); await trycatch("微信", this.wecomWebhook.bind(this)); await trycatch("PushPlus", this.pushplus.bind(this)); + await trycatch("Server酱", this.serverPush.bind(this)); } }