GitHub Actions Certification
Reusable Workflows and Reporting
Slack Notify GitHub Action
Integrate Slack notifications into your GitHub Actions CI/CD pipeline using the rtCamp/action-slack-notify@v2
action. This guide covers setting up a Slack Incoming Webhook, securing it as a GitHub secret, and adding a notification job that always runs.
1. Overview
The Slack Notify action sends a customizable message to your Slack channel at the end of a workflow. You provide it with environment variables for configuration:
Variable | Description | Example |
---|---|---|
SLACK_WEBHOOK | Your Slack Incoming Webhook URL (secret) | ${{ secrets.SLACK_WEBHOOK }} |
SLACK_CHANNEL | Channel name or ID | general |
SLACK_COLOR | Attachment color (good , #ff0000 , etc.) | ${{ job.status }} |
SLACK_ICON | URL for a custom icon | https://github.com/rtCamp.png?size=48 |
SLACK_MESSAGE | The notification text | "Build *${{ github.workflow }}* completed" |
SLACK_TITLE | Title shown above the message | "CI/CD Pipeline" |
SLACK_USERNAME | Username for the Slack bot | rtCamp |
Here’s a minimal step configuration:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: general
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://github.com/rtCamp.png?size=48
SLACK_MESSAGE: "Build *${{ github.workflow }}* completed"
SLACK_TITLE: "CI/CD Pipeline"
SLACK_USERNAME: rtCamp
2. Create a Slack Channel & Webhook
- In Slack, create a new channel (e.g.,
github-actions-channel
). - Visit Incoming Webhooks in the Slack API and click Create an App → From scratch.
- Enable Incoming Webhooks and add to your channel.
- Select your channel; Slack generates a Webhook URL. Test it with:
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"Hello, World!"}' YOUR_WEBHOOK_URL_HERE
3. Store the Webhook as a GitHub Secret
- Navigate to your repo’s Settings → Secrets and variables → Actions.
- Click New repository secret and add:
- Name:
SLACK_WEBHOOK
- Value:
<your-slack-webhook-url>
- Name:
Warning
Keep your Webhook URL confidential. Anyone with this URL can post messages to your Slack channel.
4. Add the Slack Notification Job
Append this job to your workflow file (e.g., .github/workflows/solar-system.yml
). It uses if: always()
so it runs regardless of success, failure, or cancellation, and continue-on-error: true
to avoid blocking the pipeline.
jobs:
# ... other jobs ...
slack-notification:
if: always()
name: Slack Notification
needs: [dev-integration-testing, prod-integration-testing]
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: github-actions-channel
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://gitlab.com/sidd-harth/solar-system/-/raw/main/images/saturn.png
SLACK_MESSAGE: ":hammer_and_wrench: Triggered by ${{ github.actor }}"
SLACK_TITLE: "Pipeline Status"
Once pushed, your workflow graph will include the new notification job:
After completion, you’ll see its result in the summary:
5. Verify always()
Behavior
Even if the workflow is canceled or fails, the Slack notification runs because of if: always()
:
With this setup, every GitHub Actions run—successful, failed, or canceled—triggers a Slack notification, keeping your team informed in real time.
Links and References
Watch Video
Watch video content