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
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.
Pinning and supply-chain hygiene
A third-party action runs arbitrary code with access to your workflow token. Version tags are mutable, so @v4 can change under you without any commit in your repository.
# mutable: the tag can be repointed at any time
- uses: some/action@v4
# immutable: pin to the commit SHA, with the version in a comment
- uses: some/action@e2b3f4a5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1 # v4.1.2Key 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.