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
pnpm/action-setup: Install pnpm in CIReference for pnpm/action-setup: install the pnpm package manager and optionally run install, then pair with…
peaceiris/actions-gh-pages: Deploy to GitHub PagesReference for peaceiris/actions-gh-pages: push a built static site to the gh-pages branch using GITHUB_TOKEN…
JamesIves/github-pages-deploy-action: Deploy to PagesReference for JamesIves/github-pages-deploy-action: deploy a built folder to a GitHub Pages branch, with fold…