Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
message-circle

GitHub Action

Slack Incoming Webhook

v1.1.3

Slack Incoming Webhook

message-circle

Slack Incoming Webhook

Post a message to Slack with Incoming Webhook

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Slack Incoming Webhook

uses: tokorom/action-slack-incoming-webhook@v1.1.3

Learn more about this action in tokorom/action-slack-incoming-webhook

Choose a version

javscript-action status

GitHub Action for Slack Incoming Webhook

Feature

Simple Usage

- name: Slack Notification
  uses: tokorom/action-slack-incoming-webhook@main
  env:
    INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  with:
    text: Hello, Slack!

Here's what the Slack message would look like:

simple-sample

Advanced Usages

- name: Set COMMIT_MESSAGE
  run: echo ::set-env name=COMMIT_MESSAGE::$(echo "${{ github.event.head_commit.message }}" | tr '\n' ' ')
- name: Slack Notification on SUCCESS
  if: success()
  uses: tokorom/action-slack-incoming-webhook@main
  env:
    INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  with:
    text: Successfully automated deployment.
    attachments: |
      [
        {
          "color": "good",
          "author_name": "${{ github.actor }}",
          "author_icon": "${{ github.event.sender.avatar_url }}",
          "fields": [
            {
              "title": "Commit Message",
              "value": "${{ env.COMMIT_MESSAGE }}"
            },
            {
              "title": "GitHub Actions URL",
              "value": "${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}"
            },
            {
              "title": "Compare URL",
              "value": "${{ github.event.compare }}"
            }
          ]
        }
      ]

Here's what the Slack message would look like:

sample-advanced

Change the icon

You can change the icon for a Slack message in the Slack App settings.

Slack's new Incoming Webhooks do not allow API payloads to override the icon.

  • Open Your Apps page
  • Select your app for Incoming Webhooks
  • Select Basic Information > Display Information
  • Set any icon you like!

screenshot