Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
activity

GitHub Action

Post Workflow Status To Slack

v1.0.0

Post Workflow Status To Slack

activity

Post Workflow Status To Slack

Post workflows Succes/Failure/Cancel jonb status to Slack using bot

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Post Workflow Status To Slack

uses: kpritam/[email protected]

Learn more about this action in kpritam/slack-job-status-action

Choose a version

Post Workflow Status To Slack

This action sends message to slack based on Job Status. Gihub action sets the value for Job Status i.e. ${{ job.status }} based on whether step succeeded/failed/cancelled.

Possible values assinged to job status are follows:

  1. Success
  2. Failure
  3. Cancelled

This action sends message using Slack bot tokens.

Inputs

job-status

(Required) The {{ job.status }} used to decide slack message content i.e. status, color

Status Color Hex Color Name
Success #00FF00 Pure Lime Green
Failure #FF0000 Pure Red
Cancelled #EE6F47 Bright Red

slack-bot-token

(Required) The slack bot token required to post slack message

channel

(Required) Slack channel where job status message will be posted

Usage

Here's an example of a workflow which has two jobs:

  1. success-notification: Sends job succeeded message to github-actions-test slack channel

  2. failure-notification: Sends job failed message to github-actions-test slack channel

name: Test

on:
  push:
    branches:
      - master

jobs:
  success-notification:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: exit 0
      - name: Slack Success
        if: always()
        uses: ./
        with:
          job-status: ${{ job.status }}
          slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
          channel: github-actions-test

  failure-notification:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: exit 1
      - name: Slack Failure
        if: always()
        uses: ./
        with:
          job-status: ${{ job.status }}
          slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
          channel: github-actions-test

Slack message for build success or failure would look like this:

Slack Bot Setup

This action is inspired from slack-action, follow instruction here for setting up slack bot.