Skip to content

GitHub Action to send a message to a single or to multiple webhooks at once

License

Notifications You must be signed in to change notification settings

Netail/webhook-notifier

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Webhook Notifier

A GitHub Action to concurrently send the same message to multiple different webhooks.

Currently supports the following platforms:

  • Discord
  • Slack
  • Microsoft Teams

Getting Started

Create a new GitHub Actions workflow (e.g. .github/workflows/notifier.yml)

Example workflow

An example of the GitHub Actions workflow

name: 'Pull Request Notifier'

on:
  pull_request:
    types: [opened]

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
    - uses: Netail/webhook-notifier@v1
      with:
        discord-url: 'https://discord.com/api/webhooks/...'
        slack-url: 'https://hooks.slack.com/services/..., https://hooks.slack.com/services/...'
        teams-url: '["https://outlook.office.com/webhook/...", "https://outlook.office.com/webhook/..."]'
        color: 'info'
        title: '${{ github.event.pull_request.user.login }} opened PR-${{ github.event.number }} in ${{ github.event.repository.name }}'
        text: ${{ github.event.pull_request.title }}
        fields: '[{"name": "Repository", "value": "${{ github.event.repository.name }}"}, {"name": "Pull Request ID", "value": "${{ github.event.number }}"}]'
        buttons: '[{"label": "View PR", "url": "${{ github.event.pull_request.html_url }}"}]'

Inputs

The action has any of the follow inputs

Name Description Default Notes
dry-run Prevent sending the payload false
discord-url Discord Webhook URL(s) N/A Optional: Can be comma separated values, or stringified JSON array of strings. Discord does not support buttons in incoming webhooks, yet
slack-url Slack Webhook URL(s) N/A Optional: Can be comma separated values, or stringified JSON array of strings.
teams-url Teams Webhook URL(s) N/A Optional: Can be comma separated values, or stringified JSON array of strings.
color Color of the message success Value can be in hexadecimal or the title of a predefined color
title Text at the top of the message Hello world!
text Text to be displayed under the title N/A
fields Extra info to be displayed under the message N/A Stringified JSON array of objects with the attributes name and value ( e.g. '[{"name": "string", "value": "string"}]')
buttons Additional buttons under the message N/A Stringified JSON array of objects with the attributes label and url ( e.g. '[{"label": "string", "url": "string"}]')

Predefined colors

Name Hexadecimal
success #28A745
opened
failure #CB2431
closed
merged #6F42C1
info #0366D5
warning #FFC107
cancelled #959DA5