Send GitHub Actions Workflow Notifications to Slack and Discord
Learn how to enhance your GitHub Actions workflows with real-time notifications to Slack and Discord, complete with status, duration, links, and more.
Why Send Workflow Notifications?
Whether youβre running CI/CD pipelines, deployment scripts, or automated tasks, itβs helpful to receive real-time notifications about your workflow status. Slack and Discord are great platforms to stay updated without checking GitHub constantly. In this guide, youβll learn how to integrate Slack and Discord notifications into your GitHub Actions workflows.
Prerequisites
- A GitHub repository using GitHub Actions
- A Discord server or a Slack workspace
- Permissions to create incoming webhooks
Step 1: Create Incoming Webhooks
Discord
- Create or open a Discord server.
- Go to a text channel > Edit Channel > Integrations > Webhooks.
- Click New Webhook, name it, choose a channel, and copy the URL.
Slack
- Visit Slack API: Apps and create a new app.
- Enable Incoming Webhooks.
- Add a new webhook to a channel and copy the generated URL.
π You cannot send messages directly to a Discord or Slack user via webhooks β only to channels.
Step 2: Add Webhook URLs to GitHub Secrets
In your GitHub repo:
- Navigate to Settings > Secrets and variables > Actions
Add:
DISCORD_WEBHOOK_URLSLACK_WEBHOOK_URL
Step 3: Enhanced Workflow Example
The following workflow sends detailed status updates, including:
- β /β Status
- π Build duration
- π Link to the run
- π¦ Branch name
- π§ Author
- π¬ Commit message
Discord Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set start time
id: start
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT
- name: Run your script
run: echo "Simulating build..."
- name: Calculate duration
id: duration
run: |
end_time=$(date +%s)
start_time=$
duration=$((end_time - start_time))
echo "duration=${duration}" >> $GITHUB_OUTPUT
- name: Send Discord Notification
if: always()
run: |
duration="$"
minutes=$((duration / 60))
seconds=$((duration % 60))
duration_formatted="${minutes}m ${seconds}s"
if [ "$" == "success" ]; then
emoji="β
"
status="Success"
else
emoji="β"
status="Failure"
fi
curl -H "Content-Type: application/json" \
-X POST \
-d "{
\"content\": \"${emoji} **${status}** - [$](https://github.com/$/actions/runs/$)\\n
**Branch:** \`$\`\\n
**Author:** $\\n
**Duration:** ${duration_formatted}\\n
**Message:** _$_ \"
}" \
$
Slack Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- name: Send Slack Notification
if: always()
run: |
duration="$"
minutes=$((duration / 60))
seconds=$((duration % 60))
duration_formatted="${minutes}m ${seconds}s"
if [ "$" == "success" ]; then
color="#2eb886"
status="β
*Success*"
else
color="#e01e5a"
status="β *Failure*"
fi
curl -X POST -H 'Content-type: application/json' \
--data "{
\"attachments\": [
{
\"color\": \"${color}\",
\"title\": \"GitHub Actions β ${status}\",
\"title_link\": \"https://github.com/$/actions/runs/$\",
\"fields\": [
{
\"title\": \"Workflow\",
\"value\": \"$\",
\"short\": true
},
{
\"title\": \"Branch\",
\"value\": \"$\",
\"short\": true
},
{
\"title\": \"Author\",
\"value\": \"$\",
\"short\": true
},
{
\"title\": \"Duration\",
\"value\": \"${duration_formatted}\",
\"short\": true
},
{
\"title\": \"Commit Message\",
\"value\": \"$\"
}
]
}
]
}" $
Final Thoughts
This setup is easy to implement and gives you fast feedback on your CI/CD process, especially when working across teams. You can also:
- Add emojis to differentiate build types π§ͺπ§π
- Use conditionals to notify only on failure or success
- Extend to Microsoft Teams, Telegram, or email with similar logic
Let your bots work for you β and stop refreshing GitHub π
Need a working repo or want to add colored embeds? Let me know!