Post

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.

Send GitHub Actions Workflow Notifications to Slack and Discord

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

  1. Create or open a Discord server.
  2. Go to a text channel > Edit Channel > Integrations > Webhooks.
  3. Click New Webhook, name it, choose a channel, and copy the URL.

Slack

  1. Visit Slack API: Apps and create a new app.
  2. Enable Incoming Webhooks.
  3. 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_URL
    • SLACK_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!

This post is licensed under CC BY 4.0 by the author.