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:
- Success
- Failure
- Cancelled
This action sends message using Slack bot tokens.
(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 |
(Required) The slack bot token required to post slack message
(Required) Slack channel where job status message will be posted
Here's an example of a workflow which has two jobs:
-
success-notification
: Sends job succeeded message togithub-actions-test
slack channel -
failure-notification
: Sends job failed message togithub-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: kpritam/slack-job-status-action@v1
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: kpritam/slack-job-status-action@v1
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:
This action is inspired from slack-action, follow instruction here for setting up slack bot.