With Parameters
| key | value | default |
|---|---|---|
| status | 'success' or 'failure' or 'cancelled' or 'custom' | required |
| fields | You can choose the items you want to add to the fields at the time of notification. | 'repo,commit' |
| text | Specify the text you want to add. All strings will be overwritten. | '' |
| author_name | It 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_mention | Specify 'success' or 'failure' or 'cancelled' or 'always'. Multiple statuses can be specified in csv format. | '' |
| username | Override the legacy integration’s default name. | '' |
| icon_emoji | emoji code string to use in place of the default icon. | '' |
| icon_url | icon image URL string to use in place of the default icon. | '' |
| channel | Override the legacy integration’s default channel. This should be an ID, such as C8UJ12P4P. | '' |
| custom_payload | e.g. {"text": "Custom Field Check", obj: 'LOWER CASE'.toLowerCase()} | '' |
| job_name | If you want to overwrite the job name, you must specify it. | '' |
| success_message | Message to use when the status is 'success' and text is empty. | ':white_check_mark: Succeeded GitHub Actions\n' |
| cancelled_message | Message to use when the status is 'cancelled' and text is empty. | ':warning: Cancelled GitHub Actions\n' |
| failure_message | Message to use when the status is 'failure' and text is empty. | ':no_entry: Failed GitHub Actions\n' |
| github_token | Use this if you wish to use a different GitHub token than the one provided by the workflow. | ${{ github.token }} |
| github_base_url | Specify if you want to use GitHub Enterprise. | '' |
status
Section titled “status”Recommend ${{ job.status }}.
steps: - uses: h3y6e/action-slack@v4 with: status: ${{ job.status }} env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # requiredsteps: - uses: h3y6e/action-slack@v4 with: status: ${{ job.status }} text: 'any string' env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # requiredauthor_name
Section titled “author_name”steps: - uses: h3y6e/action-slack@v4 with: status: ${{ job.status }} author_name: 'my workflow' env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # requiredmention
Section titled “mention”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 }} # requiredIf 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 }} # requiredIf 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 }} # requiredusername
Section titled “username”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 }} # requiredicon_emoji
Section titled “icon_emoji”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 }} # requiredicon_url
Section titled “icon_url”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 }} # requiredchannel
Section titled “channel”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 }} # requiredcustom_payload
Section titled “custom_payload”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 }} # requiredSee here for custom_payload reference.
- Message Formatting
- Enter json and check in preview.
- Reference: Message payloads
job_name
Section titled “job_name”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 }} # requiredsuccess_message
Section titled “success_message”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 }} # requiredcancelled_message
Section titled “cancelled_message”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 }} # requiredfailure_message
Section titled “failure_message”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 }} # requiredgithub_token
Section titled “github_token”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 }} # requiredgithub_base_url
Section titled “github_base_url”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