Skip to content

:octocat: Notify the result of Github Actions to a slack channel about the status of the workflows.

Notifications You must be signed in to change notification settings

brandoncollins7/slack-action-with-image

 
 

Repository files navigation

Notification MIT license Maintained by Craftech.io

Slack Action

This action sends a notification of the current status of the job. The possible values for the status are: success, failure, or cancelled.

First steps, you need to set GitHub secrets for SLACK_WEBHOOK_URL that is Incoming Webhook URL. You can customize the following parameters:

Inputs variables

With Parameter Required/Optional Description
slack_webhook_url Required The Slack Incoming Webhooks URL.
Please specify the environment secret for SLACK_WEBHOOK_URL
status Optional The result of GitHub Actions job
This parameter value must contain the following word:
- success
- failure
- cancelled
default is using ${{ job.status }}
slack_channel Optional Override the default incoming Webhook Slack settings
slack_username Optional Override the default incoming Webhook Slack settings

Usage

usage with the default incoming Webhook Slack settings,

Create the file workflow.yml in .github/workflows folder.

name: The name of your workflow
on [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: craftech-io/slack-action@v1
        with:
          slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: always()
  

Scenarios

You can override the default incoming Webhook Slack settings for the channel and username, also only send notification to slack if the job failure, e.g:

Possible values are success, failure, or cancelled.

name: The name of your workflow
on [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: craftech-io/slack-action@v1
        with:
          slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
          slack_channel: general
          slack_username: Github
          status: failure
        if: failure()
  

Slack UI

Locate the Slack conversation the message was sent to and it should be waiting for you, like this:

Notification Preview

Amazing work - you've now implemented notifactions the your workflows!

About

:octocat: Notify the result of Github Actions to a slack channel about the status of the workflows.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%