A powerful GitHub Action to send rich formatted messages to any Slack channel using a Slack bot.
- π¨ Send messages to any Slack channel using channel ID
- π¨ Support for rich Slack markdown formatting
- π§΅ Thread support (reply to existing messages)
- π Link and media unfurling options
- π Get message permalinks as outputs
- β Comprehensive error handling and logging
You have two options for setting up the Slack bot:
A shared bot is available for everyone to use! Simply use the SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC
secret in your workflows - no additional setup required.
- name: Send Slack notification
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C1234567890'
message: 'Hello from GitHub Actions! π'
If you prefer to use your own bot:
- Go to Slack API and create a new app
- Navigate to "OAuth & Permissions" in your app settings
- Add the following bot token scopes:
chat:write
- Send messageschat:write.public
- Send messages to channels the bot isn't inchannels:read
- Read public channel informationgroups:read
- Read private channel information (optional)
- Install the app to your workspace
- Copy the "Bot User OAuth Token" (starts with
xoxb-
)
Add your Slack bot token as a GitHub secret:
- Go to your repository Settings β Secrets and variables β Actions
- Add a new secret (e.g.,
SLACK_BOT_TOKEN
) with your bot token as the value
To find your Slack channel ID:
- Open Slack in a web browser
- Navigate to the channel you want to send messages to
- Look at the URL - the channel ID is the string after
/archives/
(e.g.,C1234567890
)
For private channels, you must invite the bot to the channel first:
- In the private channel, type:
/invite @BotName
(replace with your bot's name) - Or go to the channel settings β Members β Add people β search for your bot
- Without this step, you'll get a "channel not found" error
The bot needs to be a member of private channels to send messages there, even with proper permissions.
name: Slack Notification
on:
push:
branches: [main]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Slack notification
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C1234567890'
message: 'Hello from GitHub Actions! π'
- name: Deploy notification
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C1234567890'
message: |
π *Deployment Successful!*
β’ Repository: `${{ github.repository }}`
β’ Branch: `${{ github.ref_name }}`
β’ Commit: <${{ github.event.head_commit.url }}|${{ github.sha }}>
β’ Actor: @${{ github.actor }}
View the deployment: https://my-app.com
unfurl-links: true
- name: Send with custom bot
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.CUSTOM_SLACK_TOKEN }}
channel-id: 'C1234567890'
message: 'Message from custom bot'
- name: Send thread reply
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C1234567890'
message: 'This is a reply in the thread'
thread-ts: '1234567890.123456' # timestamp of parent message
Input | Description | Required | Default |
---|---|---|---|
slack-bot-token |
Slack Bot Token (xoxb-...) for authenticating with the Slack API | Yes | - |
channel-id |
Slack channel ID where the message should be sent | Yes | - |
message |
Message content to send. Supports Slack markdown formatting | Yes | - |
thread-ts |
Timestamp of the parent message to reply in thread | No | - |
unfurl-links |
Whether to unfurl links in the message | No | true |
unfurl-media |
Whether to unfurl media in the message | No | true |
Link unfurling (unfurl-links
) controls whether Slack automatically generates rich previews for URLs in your message. When enabled (default), links to GitHub, websites, and other services will show expanded previews with titles, descriptions, and metadata. When disabled, links appear as plain clickable text.
Media unfurling (unfurl-media
) works similarly but specifically for media content like images, videos, and audio files. When enabled, media URLs will display inline previews.
Set these to false
if you want cleaner, more compact messages without automatic previews.
Output | Description |
---|---|
message-ts |
Timestamp of the sent message |
channel |
Channel where the message was sent |
permalink |
Permalink to the sent message |
This action supports Slack's markdown formatting:
- Bold:
*bold text*
- Italic:
_italic text_
Code
:`code`
- Code blocks:
```code block```
- Links:
<https://example.com|Link text>
- User mentions:
<@U1234567890>
- Channel mentions:
<#C1234567890>
- Lists: Use
β’
or*
for bullet points
The action provides comprehensive error handling:
- β Missing required inputs
- β Invalid Slack tokens
- β Channel not found or insufficient permissions
- β API rate limiting
- β Network connectivity issues
All errors are logged with clear messages to help with debugging.
"Channel not found" error:
- For private channels: Make sure the bot is invited to the channel first (
/invite @BotName
) - For public channels: Verify the channel ID is correct
- Check that the bot has the
chat:write
andchat:write.public
scopes
name: CI/CD Pipeline
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
# ... your test steps ...
- name: Notify test results
if: always()
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C1234567890'
message: |
${{ job.status == 'success' && 'β
' || 'β' }} Tests ${{ job.status }}
β’ Repository: `${{ github.repository }}`
β’ PR: #${{ github.event.number }}
β’ Commit: `${{ github.sha }}`
- name: Security alert
uses: agglayer/gha-notify-generic@v1
with:
slack-bot-token: ${{ secrets.SLACK_APP_TOKEN_AGGLAYER_NOTIFY_GENERIC }}
channel-id: 'C9876543210' # security channel
message: |
π¨ *Security Alert*
Suspicious activity detected in repository `${{ github.repository }}`
Details:
β’ Event: ${{ github.event_name }}
β’ Actor: ${{ github.actor }}
β’ Time: ${{ github.event.head_commit.timestamp }}
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.