All Projects → actions-ecosystem → action-slack-notifier

actions-ecosystem / action-slack-notifier

Licence: Apache-2.0 license
🔔 GitHub Action to send notifications to Slack

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to action-slack-notifier

action-lgtm-reaction
GitHub Action to send LGTM reaction
Stars: ✭ 62 (+226.32%)
Mutual labels:  actions
juejin-actions
掘金每天自动签到 github actions 。组织了每周一起学习200行左右的【源码共读】活动,感兴趣可以加我微信 ruochuan12 参与。
Stars: ✭ 47 (+147.37%)
Mutual labels:  actions
action-homebrew-bump-formula
⚙️ A GitHub Action to easily bump Homebrew formula on new release
Stars: ✭ 68 (+257.89%)
Mutual labels:  actions
launchbar
Actions repository for LaunchBar 6
Stars: ✭ 65 (+242.11%)
Mutual labels:  actions
material-about
An about screen to use in your Mobile apps.
Stars: ✭ 37 (+94.74%)
Mutual labels:  actions
eslint-action
Github action that runs ESLint on javascript code.
Stars: ✭ 81 (+326.32%)
Mutual labels:  actions
gcloud-login-action
A Github Action which can be used to authenticate with Google Cloud Container Registry
Stars: ✭ 21 (+10.53%)
Mutual labels:  actions
changelog-enforcer
A simple GitHub action that enforces that a maintained changelog is kept up to date.
Stars: ✭ 32 (+68.42%)
Mutual labels:  actions
actionlint
Static checker for GitHub Actions workflow files
Stars: ✭ 1,385 (+7189.47%)
Mutual labels:  actions
actions
Our Library of GitHub Actions
Stars: ✭ 49 (+157.89%)
Mutual labels:  actions
yaml-update-action
Update YAML property with dynamic values
Stars: ✭ 81 (+326.32%)
Mutual labels:  actions
winrar-keygen
Principle of WinRAR key generation.
Stars: ✭ 398 (+1994.74%)
Mutual labels:  actions
action-dynamic-readme
~ Dynamic ReadME Generator ~
Stars: ✭ 29 (+52.63%)
Mutual labels:  actions
set-env-to-github env
A migration tools convert `::set-env`/`::set-output`/`::save-state` to $GITHUB_ENV/$GITHUB_OUTPUT/$GITHUB_STATE on GitHub Actions.
Stars: ✭ 27 (+42.11%)
Mutual labels:  actions
cobertura-action
GitHub Action to report cobertura coverage
Stars: ✭ 43 (+126.32%)
Mutual labels:  actions
azure-static-website-deploy
Deploys static website to Azure Storage
Stars: ✭ 18 (-5.26%)
Mutual labels:  actions
actions-suggest-related-links
A GitHub Action to suggest related or similar issues, documents, and links. Based on the power of NLP and fastText.
Stars: ✭ 23 (+21.05%)
Mutual labels:  actions
recent-activity
Add your recent activity to your profile readme!
Stars: ✭ 87 (+357.89%)
Mutual labels:  actions
clang-format-action
GitHub Action for clang-format checking
Stars: ✭ 48 (+152.63%)
Mutual labels:  actions
github-actions-watcher
A CLI tool to see the status of your all GitHub Actions workflows in real time
Stars: ✭ 111 (+484.21%)
Mutual labels:  actions

Action Slack Notifier

actions-workflow-test release license

screenshot

This is a GitHub Action to send notifications to Slack on general purpose.

This action is designed to focus on sending notifications, so you can flexibly customize your workflow with this action. For example, sending a message to you when a job status changes, you get a comment in an issue, a label is added to your pull request, and so on.

It would be more useful to use this with other GitHub Actions' outputs.

Prerequisites

Before getting started, let's create a Slack app!

This action requires the permission chat:write or optionally chat:write.customize. If you want to change the icon for a message, choose chat:write.customize.

If you're not familiar with creating a Slack app, see the guide below.

Slack App Setup
  1. Create a Slack app

Visit https://api.slack.com/apps and then create an app in your workspace.

screenshot

  1. Add a permission to the app

Visit https://api.slack.com/apps/<YOUR_APP_ID>/oauth and then add a permission to your app.

screenshot

  1. Install the app

Visit https://api.slack.com/apps/<YOUR_APP_ID>/install-on-team and then install your app in your workspace.

screenshot

  1. Add the app to a channel

Open a Slack channel and add the app.

Inputs

NAME DESCRIPTION TYPE REQUIRED DEFAULT
slack_token A Slack token. string true N/A
channel A channel that will receives the message. e.g.) develop, #develop string true N/A
message A message for the channel. Supports Markdown format. string true N/A
username An username who sends a message. string false GitHub Actions
color A color of a message. The color names {black, red, green, yellow, blue, magenta, cyan, white} and color code (e.g., #4CAF50) are available. The default is no-color. string false N/A
verbose Whether message contains GitHub context: repository, ref, workflow, event, action, number bool false false
unfurl Whether to unfurl links and media in a message. bool false true
custom_payload A custom payload, in the form of JSON of a Slack block array, overriding the whole message. If this is specified, inputs.color and inputs.verbose are ignored. string false N/A

inputs.custom_payload allows advanced users to send any form of message. Block Kit Builder helps you to build a JSON payload for this.

Behaviors

color: green verbose: true

screenshot

color: '' verbose: true

screenshot

color: green verbose: false

screenshot

color: '' verbose: false

screenshot

Color Palettes

Black

screenshot

Red

screenshot

Green

screenshot

Yellow

screenshot

Blue

screenshot

Magenta

screenshot

Cyan

screenshot

White

screenshot

Example

Simple

name: Notify push

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions-ecosystem/action-slack-notifier@v1
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          message: |
            @${{ github.actor }} pushed commits.
          channel: develop

Send a notification when the previous job fails

screenshot

Configuration
name: Test

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: "12.x"
      - run: yarn install
      - run: yarn test
      - uses: actions-ecosystem/action-slack-notifier@v1
        if: ${{ failure() }}
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          message: |
            @${{ github.actor }} test failed.
          channel: develop
          color: red # optional
          verbose: true # optional

Propagate mentions from GitHub to Slack

screenshot screenshot

Configuration
name: Propagate Mentions

on:
  issue_comment:
    types:
      - created

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions-ecosystem/action-regex-match@v2
        id: regex-match
        with:
          regex: '^\/cc(( +@[-\w]+)+)\s*$'
          text: ${{ github.event.comment.body }}
          flags: 'gm'

      - uses: actions-ecosystem/action-slack-notifier@v1
        if: ${{ steps.regex-match.outputs.match != '' }}
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          message: |
            ${{ steps.regex-match.outputs.match }}
          channel: develop
          color: blue # optional
          verbose: true # optional

Send a notification when a specific label is added

screenshot

Configuration
name: Notify Labeled

on:
  issues:
    types:
      - labeled

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions-ecosystem/action-slack-notifier@v1
        if: ${{ github.event.label.name == 'help wanted' }}
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          message: |
            `${{ github.event.label.name }}` label has been added.
          channel: develop
          color: blue # optional
          verbose: true # optional

Send a custom payload

screenshot

Configuration
name: Send Custom Payload

on: push

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions-ecosystem/action-slack-notifier@v1
        with:
          slack_token: ${{ secrets.SLACK_TOKEN }}
          channel: develop
          message: 'This text is for notifications.'
          custom_payload: |
            {
              "blocks": [
                {
                  "type": "section",
                  "text": {
                    "type": "mrkdwn",
                    "text": "> message *with some bold text* and _some italicized text_."
                  }
                },
                {
                  "type": "section",
                  "text": {
                    "type": "mrkdwn",
                    "text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
                  }
                },
                {
                  "type": "section",
                  "text": {
                    "type": "plain_text",
                    "text": "This is a plain text section block.",
                    "emoji": true
                  }
                },
                {
                  "type": "context",
                  "elements": [
                    {
                      "type": "mrkdwn",
                      "text": "For more info, contact <[email protected]>"
                    }
                  ]
                }
              ]
            }

License

Copyright 2020 The Actions Ecosystem Authors.

Action Slack Notifier is released under the Apache License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].