Skip to content

LunaOn/actions.notify

 
 

Repository files navigation

actions.notify

A GitHub Action to send a message to IM(Lark(飞书), Slack, Telegram). Inspired by Slack Notify

Screenshot

Lark (飞书)

Usage

You can use this action after any other action. Here is an example setup of this action:

  1. Create a .github/workflows/notify.yml file in your GitHub repo.
  2. 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 }}
  1. Create NOTIFY_WEBHOOK and NOTIFY_SIGNKEY secret using GitHub Action's Secret. And you can generate the value from the platform you are using.

Advanced

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.

For Lark

what if you want to send a image as content?

  1. use enable_image args, set it to
  enable=true
  url='local image path'
  title='use to alt image info'
  1. 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

Support

  • Lark (飞书)
  • Slack
  • Telegram

Issues

  • Q: Lark's signature cheking still has problem, and I don't know why yet. so try not to open signature checking.
  • A: WIP

About

Notify changes to Lark

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 81.6%
  • JavaScript 18.4%