A GitHub Action to send a message to IM(Lark(飞书), Slack, Telegram). Inspired by Slack Notify
You can use this action after any other action. Here is an example setup of this action:
- Create a
.github/workflows/notify.yml
file in your GitHub repo. - Add the following code to the
notify.yml
file.
on: push
name: IM Notification Demo
jobs:
notification:
name: IM Notification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Notify to IM
uses: echoings/[email protected]
with:
plat_type: 'Lark'
notify_title: 'Project Updated'
notify_message: 'Project updated, please check projects online status'
env:
NOTIFY_WEBHOOK: ${{ secrets.NOTIFY_WEBHOOK }}
NOTIFY_SIGNKEY: ${{ secrets.NOTIFY_SIGNKEY }}
# for Lark use
LARK_APP_ID: ${{ secrets.LARK_APP_ID }}
LARK_APP_SECRECT: ${{ secrets.LARK_APP_SECRECT }}
- Create
NOTIFY_WEBHOOK
andNOTIFY_SIGNKEY
secret using GitHub Action's Secret. And you can generate the value from the platform you are using.
What if notify format is not suitable for your case or your using platform isn't included?
Create a .echo.actions.notify.js
file in your root project, and export an async function which's definition as follow, and set plat_type
to Custom
then You can handle notify yourself
module.exports = async function notify(
options: {
envs: process.env,
ctx: github.context
},
utils: {
axios: 'axios',
core: '@actions/core',
github: '@actions/github'
}
): {
code: number,
data: any,
msg: string
}
Tips:
If you need more extra dependency package, please do and use ncc to bundle them together.
what if you want to send a image as content?
- use enable_image args, set it to
enable=true
url='local image path'
title='use to alt image info'
- you need to create your own business application to get app_id and app_secret, and set them as github secrect and env values:
LARK_APP_ID: app_id,
LARK_APP_SECRECT: app_secret
- Lark (飞书)
- Slack
- Telegram
- Q: Lark's signature cheking still has problem, and I don't know why yet. so try not to open signature checking.
- A: WIP