mirror of
https://github.com/seepine/action-wechat-work.git
synced 2025-01-18 13:16:38 +08:00
init
This commit is contained in:
parent
fcc3b78bbc
commit
6f94912a33
20
.editorconfig
Normal file
20
.editorconfig
Normal file
@ -0,0 +1,20 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
|
||||
# Change these settings to your own preference
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# We recommend you to keep these unchanged
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
31
.github/workflows/main.yml
vendored
31
.github/workflows/main.yml
vendored
@ -1,12 +1,21 @@
|
||||
workflow "Send notification on push" {
|
||||
on = "push"
|
||||
resolves = [
|
||||
"WeChat Work notification",
|
||||
]
|
||||
}
|
||||
name: Send notification on push
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
send-msg:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- 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:
|
||||
- '@all'
|
||||
- andreiguan
|
||||
mentioned_mobile_list:
|
||||
- '@all'
|
||||
- 15002085767
|
||||
|
||||
action "WeChat Work notification" {
|
||||
uses = "chf007/action-wechat-work@master"
|
||||
secrets = ["WECHAT_WORK_WEBHOOK"]
|
||||
args = "A new commit has been pushed to chf007/action-wechat-work."
|
||||
}
|
||||
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
||||
FROM mhart/alpine-node:10.15.1
|
||||
|
||||
LABEL "com.github.actions.name"="GitHub Action for WeChat Work"
|
||||
LABEL "com.github.actions.description"="Outputs a message to WeChat Work."
|
||||
LABEL "com.github.actions.icon"="hash"
|
||||
LABEL "com.github.actions.color"="red"
|
||||
|
||||
LABEL "repository"="https://github.com/chf007/action-wechat-work"
|
||||
LABEL "homepage"="https://github.com/chf007/action-wechat-work"
|
||||
LABEL "maintainer"="chf007 <chf007server@gmail.com>"
|
||||
LABEL "version"="0.0.1"
|
||||
|
||||
ADD entrypoint.js package.json package-lock.json /
|
||||
RUN npm ci
|
||||
RUN chmod +x /entrypoint.js
|
||||
|
||||
ENTRYPOINT ["node", "/entrypoint.js"]
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Nicolas Coutin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
26
README.md
26
README.md
@ -1 +1,25 @@
|
||||
# action-wechat-work
|
||||
# WeChat Work for GitHub Actions
|
||||
|
||||
Sends a WeChat Work notification. Simple as that.
|
||||
|
||||
![WeChat Work Logo](wechat-work-logo.png "WeChat Work Logo")
|
||||
|
||||
*Appearance on WeChat Work :*
|
||||
|
||||
![WeChat Work message](action-message.png "WeChat Work message")
|
||||
|
||||
<hr/>
|
||||
|
||||
## Usage
|
||||
|
||||
```hcl
|
||||
action "WeChat Work notification" {
|
||||
uses = "chf007/action-wechat-work@master"
|
||||
secrets = ["WECHAT_WORK_BOT_WEBHOOK"]
|
||||
}
|
||||
```
|
||||
|
||||
### Secrets
|
||||
|
||||
* **`WECHAT_WORK_BOT_WEBHOOK`**: the WeChat Work webhook URL (**required**, see https://work.weixin.qq.com/api/doc#90000/90136/91770).
|
||||
* That's all.
|
||||
|
31
entrypoint.js
Normal file
31
entrypoint.js
Normal file
@ -0,0 +1,31 @@
|
||||
const axios = require('axios');
|
||||
const _ = require('lodash');
|
||||
const { argv } = require('yargs');
|
||||
|
||||
const payload = {
|
||||
msgtype: 'text',
|
||||
text: {
|
||||
content: `${process.env.GITHUB_REPOSITORY}/${process.env.GITHUB_WORKFLOW} triggered by ${process.env.GITHUB_ACTOR} (${process.env.GITHUB_EVENT_NAME})`,
|
||||
}
|
||||
};
|
||||
|
||||
console.log('The message content in JSON format...');
|
||||
console.log(JSON.stringify(payload));
|
||||
|
||||
const url = process.env.WECHAT_WORK_BOT_WEBHOOK;
|
||||
|
||||
(async () => {
|
||||
console.log('Sending message ...');
|
||||
await axios.post(url, JSON.stringify(payload), {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
});
|
||||
console.log('Message sent ! Shutting down ...');
|
||||
process.exit(0);
|
||||
})()
|
||||
.catch((err) => {
|
||||
console.error(err.message);
|
||||
console.error('Message :', err.response.data);
|
||||
process.exit(1);
|
||||
});
|
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "action-wechat-work",
|
||||
"version": "0.0.1",
|
||||
"description": "Sends a WeChat Work notification. Simple as that.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/chf007/action-wechat-work.git"
|
||||
},
|
||||
"author": "chf007 <chf007server@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chf007/action-wechat-work/issues"
|
||||
},
|
||||
"homepage": "https://github.com/chf007/action-wechat-work#readme"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user