slackapi/slack-github-action
Send a message to Slack from a workflow, via a bot token or an incoming webhook.
What it does
slackapi/slack-github-action sends messages to Slack so a channel sees build results. In v2 you choose a technique: call a Slack API method with a bot token, or POST to an incoming webhook.
It is the common way to alert a team when a deploy or a main-branch build fails.
Usage
workflow (.yml)
steps:
- uses: slackapi/slack-github-action@v2
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: C0123456789
text: "Build ${{ job.status }} for ${{ github.ref_name }}"Inputs
| Input | Description | Default | Required |
|---|---|---|---|
method | Slack API method to call (bot-token technique). | - | No |
token | Slack bot token (for the API method technique). | - | No |
webhook | Incoming webhook URL (webhook technique). | - | No |
webhook-type | Webhook type, e.g. incoming-webhook. | - | No |
payload | Message payload (JSON or YAML). | - | No |
Notes
v2 reorganized inputs around techniques. A v1 config will not work unchanged; consult the README when upgrading.
Common errors
not_authedorinvalid_authmeans the bot token is missing or wrong.channel_not_foundmeans the bot is not in the target channel or the ID is wrong.
Security and pinning
- Store the bot token or webhook URL as a secret. Pin the action SHA.
Frequently asked questions
Should I use a bot token or a webhook?
A bot token with chat.postMessage is more flexible (threads, updates, rich formatting). An incoming webhook is simpler for a single channel.