Skip to content
Latchkey

slackapi/slack-github-action: Send Slack Notifications

slack-github-action posts messages to Slack from your workflow, via webhook or Web API.

Notify a channel when a build fails or a deploy ships. It supports incoming webhooks and the Slack Web API with a bot token.

Key inputs (with:)

  • webhook / webhook-type: incoming webhook URL and mode.
  • method: a Slack Web API method like chat.postMessage.
  • token: a Slack bot token for Web API calls.
  • payload: the JSON message payload.

Example workflow

.github/workflows/ci.yml
jobs:
  notify:
    runs-on: ubuntu-latest
    if: failure()
    steps:
      - uses: slackapi/slack-github-action@v2
        with:
          webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
          webhook-type: incoming-webhook
          payload: |
            {"text": "Build failed on ${{ github.ref_name }}"}

On any runner

This action runs on any runner. Latchkey managed runners run it unchanged.

Key takeaways

  • Webhook mode is simplest; Web API mode is more capable.
  • Gate it with if: failure() to alert only on failures.
  • Store the webhook URL or bot token as a secret.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →