action-wechat-work/README.md

124 lines
18 KiB
Markdown
Raw Normal View History

2019-09-11 11:56:17 +08:00
# WeChat Work for GitHub Actions
2019-09-11 15:20:04 +08:00
通过企业微信机器人发送消息
2019-09-11 11:56:17 +08:00
![WeChat Work Logo](wechat-work-logo.png "WeChat Work Logo")
2019-09-11 15:20:04 +08:00
<hr/>
2019-09-11 11:56:17 +08:00
2019-09-11 15:20:04 +08:00
## 用法
2019-09-11 11:56:17 +08:00
2021-04-26 15:55:22 +08:00
### 纯文本格式消息
2019-09-11 15:20:04 +08:00
![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
2021-04-26 15:55:22 +08:00
content: 广州今日天气29 度大部分多云降雨概率60%
2019-09-11 15:20:04 +08:00
mentioned_list: '["wangqing","@all"]'
mentioned_mobile_list: '["13800001111","@all"]'
```
参数 | 必须 | 说明
------------ | ------------- | -------------
2021-04-26 15:55:22 +08:00
msgtype | true | 消息类型,此时固定为 text
content | true | 文本内容,最长不超过 2048 个字节,必须是 utf8 编码
mentioned_list | false | userid 的列表,提醒群中的指定成员(@某个成员)@all表示提醒所有人,如果开发者获取不到 userid可以使用 mentioned_mobile_list必须是序列化后的 JSON 字符串
mentioned_mobile_list | false | 手机号列表,提醒手机号对应的群成员(@某个成员)@all表示提醒所有人,必须是序列化后的 JSON 字符串
2019-09-11 15:20:04 +08:00
2021-04-26 15:55:22 +08:00
### Markdown 格式消息
2019-09-11 15:20:04 +08:00
![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>"
```
参数 | 必须 | 说明
------------ | ------------- | -------------
2021-04-26 15:55:22 +08:00
msgtype | true | 消息类型,此时固定为 markdown
content | true | markdown 内容,最长不超过 4096 个字节,必须是 utf8 编码 支持的格式详见 https://work.weixin.qq.com/api/doc/90000/90136/91770
2019-09-11 15:20:04 +08:00
2021-04-26 15:55:22 +08:00
### 图片格式消息
2019-09-11 11:56:17 +08:00
2021-04-26 15:55:22 +08:00
![WeChat Work message](wechat-work-msg-image.png "WeChat Work message")
2019-09-11 11:56:17 +08:00
2019-09-11 15:20:04 +08:00
```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
2021-04-26 15:55:22 +08:00
base64: iVBORw0KGgoAAAANSUhEUgAAAPEAAAByCAYAAACC7zd/AAAgAElEQVR4nO19CZRc1Xnm/2qv6lartXa3urUrktDeaiQBJoBBSGxWItszJDEZFMwyoBxPOGPOBBzMsZWB8XDGOMcGA7IVnMMk48nYYBmBJMAOiQwWjdQICe1rJLW6W2tvVV3rm/+7772qV/ur7nqNCt3vqPS6Xt13l//+2733v/cpPb39KklISFQsHJ91BSQkJIYGKcQSEhUOKcQSEhUOKcQSEhUOKcQSEhUOKcQSEhUOKcQSEhUOKcQSEhUOKcQSEhUOV9EUne/Qd35K9NATy6l+16v0wMs7ciSaQKu//RjdUYe/u+jNp7dSwxP3UMOWZ+mN+sfo/oW4v5t+8nQn3YV80p5NpW/mbx38zJMb21M/L7mP1q+Zb0r7DL12OvXzsgefo7s6Mp5pvJPWZZWjA21oW2jKMxvd3d104MA+Cg8MFCBMaVAUhTxeL82adRWNHDmybPlKSBQX4gw0rXqcnlo53nRHF0IW4LZXHqUXWvXbaw1hf5S2m1JvX7tJ/6uFHnleE9xMQ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Fb4nyN2xYVhBhjtAURW2iPHTG6WjmgWZzLYbrFnfZF0yVU0Y440w68aUcxYHnwlyiH25RQ7YvYQju09sRti9NGGeVCQSHGu4Q2bNhAq1atoqNHj4oXheH41lGjRomNEYilxn0c6zq/JUyJWDSLUQppnFxMlS890iLkDkrEahn5mDZfetw3FBLssbHpo5T6W6kPwiGD/f1CiCEA+fIpNf/MZ1BOKNjHDOnRlF+O/AbbBjNEe7hvuCXcP+70NKqaU+kOhi+g+BAW63K7k8I1VBplptfCLsM
md5: 0582d8564cdee3187207666898f75205
2019-09-11 11:56:17 +08:00
```
2019-09-11 15:20:04 +08:00
参数 | 必须 | 说明
------------ | ------------- | -------------
2021-04-26 15:55:22 +08:00
msgtype | true | 消息类型,此时固定为 image
base64 | true | 图片内容的 base64 编码 注图片base64 编码前)最大不能超过 2 M支持 JPG、PNG 格式
md5 | true | 图片内容base64 编码前)的 md5 值
2019-09-11 15:20:04 +08:00
2021-04-26 15:55:22 +08:00
### 图文格式消息
2019-09-11 15:20:04 +08:00
![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"}]'
```
参数 | 必须 | 说明
------------ | ------------- | -------------
2021-04-26 15:55:22 +08:00
msgtype | true | 消息类型,此时固定为 news
articles | true | 图文消息,一个图文消息支持 1 到 8 条图文,必须是序列化后的 JSON 字符串
articles.title | true | 标题,不超过 128 个字节,超过会自动截断
articles.description | false | 描述,不超过 512 个字节,超过会自动截断
2019-09-11 15:20:04 +08:00
articles.url | false | 点击后跳转的链接。
2021-04-26 15:55:22 +08:00
articles.picurl | false | 图文消息的图片链接,支持 JPG、PNG 格式,较好的效果为大图 1068*455小图 150*150。
2019-09-11 15:20:04 +08:00
2021-04-26 15:55:22 +08:00
### 文件格式消息
2019-09-11 15:20:04 +08:00
2021-04-26 15:55:22 +08:00
![WeChat Work message](wechat-work-msg-file.png "WeChat Work message")
2019-09-11 11:56:17 +08:00
2021-04-26 15:55:22 +08:00
```yaml
- name: WeChat Work notification by file
uses: chf007/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}}
with:
msgtype: file
media_id: 3a8asd892asd8asd
```
参数 | 必须 | 说明
------------ | ------------- | -------------
msgtype | true | 消息类型,此时固定为 file
2021-04-26 16:16:36 +08:00
media_id | true | 文件 id通过 [文件上传接口](https://work.weixin.qq.com/api/doc/90000/90136/91770) 获取
2021-04-26 15:55:22 +08:00
### WECHAT_WORK_BOT_WEBHOOK
2021-04-26 16:29:35 +08:00
* **`WECHAT_WORK_BOT_WEBHOOK`**: 企业微信 Webhook URL (**required**)
* 在 GitHub 仓库的 Settings - Secrets 中设置
### 更多企业微信机器人详细说明,参见 [https://work.weixin.qq.com/api/doc/90000/90136/91770](https://work.weixin.qq.com/api/doc/90000/90136/91770)