action-wechat-work/README.zh-CN.md
andreiguan ba7f10ea31 doc
2019-09-11 16:21:02 +08:00

104 lines
6.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WeChat Work for GitHub Actions
通过企业微信机器人发送消息
![WeChat Work Logo](wechat-work-logo.png "WeChat Work Logo")
<hr/>
## 用法
#### 纯文本格式消息
![WeChat Work message](wechat-work-msg-text.png "WeChat Work message")
```yaml
- name: WeChat Work notification by text
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}}
with:
msgtype: text
content: 广州今日天气29度大部分多云降雨概率60%
mentioned_list: '["wangqing","@all"]'
mentioned_mobile_list: '["13800001111","@all"]'
```
参数 | 必须 | 说明
------------ | ------------- | -------------
msgtype | true | 消息类型此时固定为text
content | true | 文本内容最长不超过2048个字节必须是utf8编码
mentioned_list | false | userid的列表提醒群中的指定成员(@某个成员)@all表示提醒所有人如果开发者获取不到userid可以使用mentioned_mobile_list必须是序列化后的JSON字符串
mentioned_mobile_list | false | 手机号列表,提醒手机号对应的群成员(@某个成员)@all表示提醒所有人必须是序列化后的JSON字符串
#### markdown格式消息
![WeChat Work message](wechat-work-msg-markdown.png "WeChat Work message")
```yaml
- name: WeChat Work notification by markdown
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}}
with:
msgtype: markdown
content: "实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。\n
> 类型:<font color=\"comment\">用户反馈</font> \n
> 普通用户反馈:<font color=\"comment\">117例</font> \n
> VIP用户反馈:<font color=\"comment\">15例</font>"
```
参数 | 必须 | 说明
------------ | ------------- | -------------
msgtype | true | 消息类型此时固定为markdown
content | true | markdown内容最长不超过4096个字节必须是utf8编码 支持的格式详见 https://work.weixin.qq.com/api/doc#90000/90136/91770
#### 图片格式消息 ❌**暂不支持**
![WeChat Work message](wechat-work-msg-images.png "WeChat Work message")
```yaml
- name: WeChat Work notification by image
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}}
with:
msgtype: image
base64: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFcAAAAjCAYAAADhe5a7AAAGIUlEQVRoQ+2aeYiNexjHP6+syZr1jiV7KMnYd/mDyOF27Vu2kCLE7YZCws1cS4gS/rCTaxl7ZEsiRkm6V4wlxr7v+7l95+edc+bMWd73LLjNeeptZt75rd/fs3yf5/1ZBBFvamohUlJ6AT2BpsAvQIlgbfPpu1fAXeA8sJusrF1WRsanQCyswBfenj1/xetNA2rlU+Ci2XYmljXV2r17p3/nHHC9UACP509gCpAH9GhmzGd9vMBfpKf/YcFX7d0HrsezAJiazwBJxHbTrPT033PA/eYK/k5qbFyw9mJZv8lFWN+C1z9JHxsXYO1BMsnKqm95PZ4+wLa4Dh3PwXr0gFKlYNs2+PgxupH79YM3b2DvXvf9NXft2vD6NVy54qZ/X4G7ARjkptd3bbtgAdSqBb17g1cxIwpZvx4ePYLJk03nEiWgcmUoWBAKFYLChc07+ylfHipWhEqVoEwZ0+fxYxg7Fj7lYVyhFrRR4P4L1ItiybF10Ubat488xoABUKAAbNwYue3Jk/BKFDRAAsGtUQOWLAk93rNncO8ePHgAd+/CtWtw9WrwsUOPckXgvnSVIAwZAp06wc6dcOAAfP4cedPBWlSvDkuXRtc3VK8JE+DWrcjgqkX9+vD1q3k+fID376FpUxgzxmh4ZqYZp107A7D9t/MVvxK4zm2tZk1YvNg3/PXrsGKFOVW3UqQISIPCidzB6NFw9CgcOhR5hhs3DFCRNNf+v3xxq1YGTIHcoYP53Qa3ZElYvRpOnw6v6SFW5g7cJk1g5szcQ335Avv2webN8PZtZADctFAwGzUK0tLg1Ck3PWHGDGjWLG+fJ09gxAjzvnlzmD4d5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HtV/3Wvudnf0H7ur7/OYM3bStagj4xiAmIEgQDK3PUcORL+q7ISFRXVMzIiF6Byr6Jv8t5CtIcXvp+5t6A2yRs3cUXYd+PGHtabvCsWL4Rz3xXL1t7kLcdYwQ19yzFHg5P3c6MBOfz9XP8RkzfLI+Lr6Gb5fxIdCIlOU4+aAAAAAElFTkSuQmCC
md5: 9c2c8daba00a516c0ff469ca13e0edf0
```
参数 | 必须 | 说明
------------ | ------------- | -------------
msgtype | true | 消息类型此时固定为image
base64 | true | 图片内容的base64编码 注图片base64编码前最大不能超过2M支持JPG,PNG格式
md5 | true | 图片内容base64编码前的md5值
#### 图文格式消息
![WeChat Work message](wechat-work-msg-news.png "WeChat Work message")
```yaml
- name: WeChat Work notification by news
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}}
with:
msgtype: news
articles: '[{"title":"中秋节礼品领取","description":"今年中秋节公司有豪礼相送","url":"URL","picurl":"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"}]'
```
参数 | 必须 | 说明
------------ | ------------- | -------------
msgtype | true | 消息类型此时固定为news
articles | true | 图文消息一个图文消息支持1到8条图文必须是序列化后的JSON字符串
articles.title | true | 标题不超过128个字节超过会自动截断
articles.description | false | 描述不超过512个字节超过会自动截断
articles.url | false | 点击后跳转的链接。
articles.picurl | false | 图文消息的图片链接支持JPG、PNG格式较好的效果为大图 1068*455小图150*150。
#### 更多详细参数说明,参见 https://work.weixin.qq.com/api/doc#90000/90136/91770
## WECHAT_WORK_BOT_WEBHOOK
* **`WECHAT_WORK_BOT_WEBHOOK`**: 企业微信 Webhook URL (**required**, 参见 https://work.weixin.qq.com/api/doc#90000/90136/91770).