Skip to content
message-circle

GitHub Action

Slack Incoming Webhook

v1.2.1 Latest version
Use latest version
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.2.1
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 "COMMIT_MESSAGE=${{ github.event.head_commit.message }}" | tr '\n' ' ' >> $GITHUB_ENV
- 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": "${{ github.event.head_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