notify-dingtalk

1.2.0 • Public • Published

notify-dingtalk

钉钉群 Markdown 消息通知。

安装

npm i notify-dingtalk -D

国内推荐使用 tbify 加速。

使用

在项目根目录创建配置文件 notify-dingtalk.config.js,然后导出配置即可:

const { defineConfig } = require('notify-dingtalk')

module.exports = defineConfig({
  accessToken: 'xxx',
  secret: 'xxx',
  title: '发布通知',
  content: '**优化**: 添加属性',
})

如果要通知到多个群,导出一个数组即可:

const { defineConfig } = require('notify-dingtalk')

module.exports = [
  defineConfig({
    accessToken: 'xxx',
    secret: 'xxx',
    title: '发布通知',
    content: '**优化**: 添加属性',
  }),
  defineConfig({
    accessToken: 'xxx2',
    secret: 'xxx2',
    title: '发布通知',
    content: '**优化**: 添加属性',
  }),
]

其中 accessTokensecret 也可以不用显式指定,而是分别通过环境变量 D_ACCESS_TOKEND_SECRET 设置。

最后,执行以下命令发送通知到钉钉群:

npx notify-dingtalk

效果如下:

一个更符合实际项目的示例

如果你的更新日志是采用 conventional-changelog 生成的,可使用包提供的 getLatestConventionalChangelog 方法获取最新的更新日志。

const {
  defineConfig,
  getLatestConventionalChangelog,
} = require('notify-dingtalk')
const { dedent } = require('vtils')

module.exports = defineConfig({
  accessToken: '******',
  secret: '******',
  title: '发布公告',
  content: dedent`
    # 发布公告

    ---

    ${getLatestConventionalChangelog('./CHANGELOG.md')}

    ---

    [进入主页→](https://github.com/fjc0k/notify-dingtalk)
  `,
})

许可

MIT (c) Jay Fong

Readme

Keywords

none

Package Sidebar

Install

npm i notify-dingtalk

Weekly Downloads

3

Version

1.2.0

License

MIT

Unpacked Size

11.1 kB

Total Files

9

Last publish

Collaborators

  • funch