With Parameters

This page describes the elements that can be specified in with.

List

keyvaluedefault
status'success' or 'failure' or 'cancelled' or 'custom'''
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.''
author_nameIt can be overwritten by specifying. The job name is recommend.'8398a7@action-slack'
mention'here' or 'channel' or user_group_id or user_id''
if_mentionSpecify 'success' or 'failure' or 'cancelled' or 'custom' or 'always'.''
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()}''

status

Recommend ${{ job.status }}.

steps:
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

text

e.g.

steps:
- uses: 8398a7/action-slack@v3
with:
text: 'any string'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

author_name

e.g.

steps:
- uses: 8398a7/action-slack@v3
with:
author_name: 'my workflow'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

mention

This can be mentioned in combination with if_mention.

steps:
- uses: 8398a7/action-slack@v3
with:
mention: 'here'
if_mention: failure
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

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

steps:
- uses: 8398a7/action-slack@v3
with:
mention: 'user_id,user_id2'
if_mention: 'failure,cancelled'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

username

Only legacy incoming webhook supported.

steps:
- uses: 8398a7/action-slack@v3
with:
username: 'my workflow bot'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

icon_emoji

Only legacy incoming webhook supported.

steps:
- uses: 8398a7/action-slack@v3
with:
icon_emoji: ':octocat:'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

icon_url

Only legacy incoming webhook supported.

steps:
- uses: 8398a7/action-slack@v3
with:
icon_url: 'http://example.com/hoge.png'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

channel

Only legacy incoming webhook supported.

steps:
- uses: 8398a7/action-slack@v3
with:
channel: '#general'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

custom_payload

steps:
- uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
text: "Custom Field Check",
attachments: [{
"author_name": "8398a7@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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required

See here for custom_payload reference.