Skip to content

With Parameters

keyvaluedefault
status'success' or 'failure' or 'cancelled' or 'custom'required
fieldsYou can choose the items you want to add to the fields at the time of notification.'repo,commit'
textSpecify the text you want to add. All strings will be overwritten.''
author_nameIt can be overwritten by specifying. The job name is recommend.'h3y6e@action-slack'
mention'here' or 'channel' or user_group_id or user_id''
if_mentionSpecify 'success' or 'failure' or 'cancelled' or 'always'. Multiple statuses can be specified in csv format.''
usernameOverride the legacy integration’s default name.''
icon_emojiemoji code string to use in place of the default icon.''
icon_urlicon image URL string to use in place of the default icon.''
channelOverride the legacy integration’s default channel. This should be an ID, such as C8UJ12P4P.''
custom_payloade.g. {"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()}''
job_nameIf you want to overwrite the job name, you must specify it.''
success_messageMessage to use when the status is 'success' and text is empty.':white_check_mark: Succeeded GitHub Actions\n'
cancelled_messageMessage to use when the status is 'cancelled' and text is empty.':warning: Cancelled GitHub Actions\n'
failure_messageMessage to use when the status is 'failure' and text is empty.':no_entry: Failed GitHub Actions\n'
github_tokenUse this if you wish to use a different GitHub token than the one provided by the workflow.${{ github.token }}
github_base_urlSpecify if you want to use GitHub Enterprise.''

Recommend ${{ job.status }}.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
text: 'any string'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
author_name: 'my workflow'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

This can be mentioned in combination with if_mention.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
mention: 'here'
if_mention: failure
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

If you want to mention multiple users in multiple cases, you can specify.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
mention: 'user_id,user_id2'
if_mention: 'failure,cancelled'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

If you want to mention a user group, you need to add “subteam^” before user group id.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
mention: 'subteam^S012ABC3Y4Z' # replace S012ABC3Y4Z with your user group id
if_mention: 'failure,cancelled'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Only legacy incoming webhook supported.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
username: 'my workflow bot'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Only legacy incoming webhook supported.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
icon_emoji: ':octocat:'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Only legacy incoming webhook supported.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
icon_url: 'http://example.com/hoge.png'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Only legacy incoming webhook supported.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
channel: '#general'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
steps:
- uses: h3y6e/action-slack@v4
with:
status: custom
custom_payload: |
{
text: "Custom Field Check",
attachments: [{
"author_name": "h3y6e@action-slack", // json
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 title1',
value: 'long value1',
short: false
}],
actions: [{
}]
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

See here for custom_payload reference.

In the action-slack, there are arguments to get the information about the job. They are retrieved from the job name and will not work if the job name is overwritten.

If you want to rename a job and get information about it, give the job a job_name.

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
job_name: Test # Match the name above.
fields: job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Message to use when the status is success and text is empty.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
success_message: ':tada: Build passed!'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Message to use when the status is cancelled and text is empty.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
cancelled_message: ':stop_sign: Build was cancelled.'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Message to use when the status is failure and text is empty.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
failure_message: ':fire: Build failed!'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Use this if you wish to use a different GitHub token than the one provided by the workflow. Defaults to ${{ github.token }}.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

Specify if you want to use GitHub Enterprise. When empty, defaults to https://github.com.

steps:
- uses: h3y6e/action-slack@v4
with:
status: ${{ job.status }}
github_base_url: 'https://github.example.com'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required