A GitHub Action that posts job-status notifications to Slack. Pass
${{ job.status }} and you get a colored success / failure /
cancellation message with commit, author, and workflow link. Supports
@here / @channel / user-id mentions, mention-only-on-failure, and
arbitrary custom payloads. Works with either a Slack App Incoming
Webhook URL or a Bot Token.
- Quick Start
- Environment Variables
- Input Parameters
- Examples
- Screenshots
- Slack App Setup
- Migration & Changelog
- uses: sonots/slack-notice-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # `secrets.GITHUB_TOKEN` is automatically provided by GitHub Actions
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} # Slack App Bot User OAuth Token which you must provide
with:
status: ${{ job.status }}
only_mention_fail: 'channel'
if: always() # Pick up events even if the job fails or is canceled.| Name | Type | Description |
|---|---|---|
GITHUB_TOKEN |
string | Required. Use ${{ secrets.GITHUB_TOKEN }}, which is automatically provided by GitHub Actions. |
SLACK_WEBHOOK_URL |
string | Required (either this or SLACK_BOT_TOKEN). Slack App Incoming Webhook URL. Triggers Webhook mode. |
SLACK_BOT_TOKEN |
string | Required (either this or SLACK_WEBHOOK_URL). Slack App Bot User OAuth Token (xoxb-…). Triggers Bot Token mode. Takes precedence over SLACK_WEBHOOK_URL when both are set. |
| Key | Type | Values | Default | Description |
|---|---|---|---|---|
status |
enum | success failure cancelled custom |
— | Required. Use ${{ job.status }} for the first three. |
text |
string | — | '' |
Override the default text on every status. |
text_on_success |
string | — | '' |
Override text on success only. Wins over text. |
text_on_fail |
string | — | '' |
Override text on failure only. Wins over text. |
text_on_cancel |
string | — | '' |
Override text on cancellation only. Wins over text. |
title |
string | — | workflow name | Attachment title. |
mention |
string | here channel <user-id> |
'' |
Mention always if specified. Comma-separate for multiple users, e.g. U024BE7LH,U987XYZAB. See Mentioning Users. |
only_mention_fail |
string | here channel <user-id> |
'' |
Mention only on failure if specified. |
payload |
object | — | — | Required when status: custom. Replaces the default message. See Custom Payload. |
Set when SLACK_BOT_TOKEN is provided. Ignored (with a warning) in
Webhook mode, since modern Slack App Incoming Webhooks drop these
fields server-side.
| Key | Type | Values | Default | Description |
|---|---|---|---|---|
channel |
string | <channel-id> #name |
'' |
Required in Bot Token mode. Destination channel for the message. |
username |
string | — | '' |
Override bot display name for this message. |
icon_emoji |
string | :emoji: |
'' |
Override bot icon with an emoji. |
icon_url |
string | — | '' |
Override bot icon with an image URL. |
There are no Webhook-mode-only inputs.
Override the default message text per status and control who gets
mentioned. text_on_* wins over text, and only_mention_fail only
fires when status is failure.
- uses: sonots/slack-notice-action@v4
with:
status: ${{ job.status }}
title: 'Build & Test'
text_on_success: ':white_check_mark: All checks passed!'
text_on_fail: ':rotating_light: Build broke — please investigate.'
text_on_cancel: ':warning: Job was cancelled.'
mention: 'channel' # always mentions @channel
only_mention_fail: 'U024BE7LH,U987XYZAB' # mentions these users only on failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()Use a Bot Token instead of an Incoming Webhook to unlock features that modern webhooks no longer support:
- Choose
channelat post time (route prod alerts to#alerts, PR noise to#ci-noisy, etc.) - Override
username/icon_emoji/icon_urlper message
- uses: sonots/slack-notice-action@v4
with:
status: ${{ job.status }}
channel: '#alerts'
username: 'CI Bot (prod)'
icon_emoji: ':rocket:'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}See Slack App Setup → Bot Token App for how to create
the app, set scopes, and obtain the xoxb-… token.
Use status: custom when you want full control over the Slack payload.
The payload input is evaluated as a JavaScript object literal, so you
can use template strings and runtime expressions.
- uses: sonots/slack-notice-action@v4
with:
status: custom
payload: |
{
text: "Custom Field Check",
attachments: [{
author_name: "sonots@slack-notice-action",
fallback: 'fallback',
color: 'good',
title: 'CI Result',
text: 'Succeeded',
fields: [
{ title: 'lower case', value: 'LOWER CASE CHECK'.toLowerCase(), short: true },
{ title: 'reverse', value: 'gnirts esrever'.split('').reverse().join(''), short: true },
{ title: 'long title', value: 'long value', short: false },
]
}]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}References:
- Reference: Message payloads
- Block Kit Builder — for richer layouts using
blocksinstead ofattachments
| Success | Failure | Cancellation |
|---|---|---|
![]() |
![]() |
![]() |
Pick one of the two transports below. You only need to set up the one you intend to use.
Simpler to set up; channel is fixed by the webhook URL. Store the URL
in the SLACK_WEBHOOK_URL repository secret.
- Open https://api.slack.com/apps and click Create New App → From scratch.
- Pick an app name and your workspace, then Create App.
- In the sidebar, open Incoming Webhooks and toggle the feature On.
- Click Add New Webhook to Workspace, choose the destination channel, and Allow.
- Copy the generated
https://hooks.slack.com/services/...URL. - Add it as a repository secret named
SLACK_WEBHOOK_URL:- GitHub UI: Settings → Secrets and variables → Actions → New repository secret, or
- CLI:
gh secret set SLACK_WEBHOOK_URL
Reference: Slack: Sending messages using Incoming Webhooks.
Pick channels per-message and override username / icon_emoji /
icon_url. Store the token in the SLACK_BOT_TOKEN repository secret.
-
Open https://api.slack.com/apps and click Create New App → From scratch.
-
Pick an app name and your workspace, then Create App.
-
In the sidebar, open OAuth & Permissions.
-
Under Bot Token Scopes, add:
Scope Why chat:writePost messages. chat:write.customizeOverride username/icon_emoji/icon_url.chat:write.publicPost to public channels without inviting the bot first. -
Click Install to Workspace at the top of the page and Allow. (If you change scopes later, use Reinstall to Workspace.)
-
Copy the Bot User OAuth Token (starts with
xoxb-…) shown on the OAuth & Permissions page. -
Add it as a repository secret named
SLACK_BOT_TOKEN:- GitHub UI: Settings → Secrets and variables → Actions → New repository secret, or
- CLI:
gh secret set SLACK_BOT_TOKEN
-
For private channels (or if you skipped
chat:write.public), invite the bot to the destination channel:/invite @YourBotName.
Reference: Slack: Token types.
- Upgrading from v3? See the v3 → v4 migration guide
in
CHANGELOG.md. - Full release history: CHANGELOG.md
This originally started as a fork of https://github.com/8398a7/action-slack. Thanks!


