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
nick-fields/retry: Retry Flaky Steps in CIReference for nick-fields/retry: re-run a command up to N times with timeouts and backoff to survive flaky ne…
actions/stale: Auto-Close Stale Issues & PRsReference for actions/stale: label and close inactive issues and pull requests on a schedule, with day thresh…
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…