Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
send

GitHub Action

Send Discord Webhook

v5.0.2

Send Discord Webhook

send

Send Discord Webhook

Send Discord webhook

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Send Discord Webhook

uses: hugoalh/send-discord-webhook-ghaction@v5.0.2

Learn more about this action in hugoalh/send-discord-webhook-ghaction

Choose a version

🌐 | English / 漢語


Send Discord Webhook (GitHub Action)

SendDiscordWebhook.GitHubAction

License GitHub Stars GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions CodeFactor Grade

Releases Latest (GitHub Latest Release Date) Pre (GitHub Latest Pre-Release Date)
GitHub GitHub Total Downloads GitHub Latest Release Version GitHub Latest Pre-Release Version

📝 Description

A GitHub Action to send a Discord webhook.

🌟 Feature

  • Support attachments/files.
  • Support thread.

📚 Documentation

⚠ Important: This documentation is v5.0.0 based; To view other version's documentation, please visit the versions list and select the correct version.

Getting Started

Install (For Self Host)

  • GitHub Actions Runner >= v2.297.0
    • NodeJS ^ v16.13.0

Use

jobs:
  job_id:
    runs-on: "________" # Any
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction@<Version>"

📥 Input

Legend Description
🔐 Should be an encrypted secret.

key

🔐 <string> Key; Both long and short forms are acceptable.

https://discord.com/api/webhooks/70971114/ueyzeWxB_8bb1zMhL  ⬅Long
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^  ⬅Short

https://discordapp.com/api/webhooks/70971114/ueyzeWxB_8bb1zMhL  ⬅Long (Legacy)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^  ⬅Short (Legacy)

method

[Optional] <string> Method to send.

  • Default: Let this action automatically determine the best method.
  • "form": Use multipart/form-data.
  • "json": Use application/json.

When this input is not defined, and input files is:

  • defined, will use "form".
  • not defined, will use "json".

When this input is "json", and input files is defined, will throw an error.

payload

[Optional] <object = {}> JSON/YAML/YML payload, which restricted format and pattern; At least one of the input payload.content, payload.embeds, or files must be provided. View the JSON payload template in here.

⚠ Important: Properties which have not listed in here or in the template are not supported.

content

[Optional] <string> Content of the message, up to 2000 characters.

username

[Optional] <string> Override the default username of the webhook, up to 80 characters; "Clyde" is not allowed.

avatar_url

[Optional] <string> Source URL of the avatar, only supports HTTP and HTTPS; Override the default avatar of the webhook.

tts

[Optional] <boolean = false> Whether to use TTS (Text To Speech) for the message.

embeds

[Optional] <object[]> Embed rich content for the message, up to 10 embeds and 6000 characters for summation of:

embeds[*].title

[Optional] <string> Title of the embed, up to 256 characters.

embeds[*].description

[Optional] <string> Description of the embed, up to 4096 characters.

embeds[*].url

[Optional] <string> URL of the embed.

embeds[*].timestamp

[Optional] <string> Timestamp of the embed, by ISO 8601 format (e.g.: "2011-11-11T11:11:11Z").

embeds[*].color

[Optional] <number | string = 2105893> Color of the embed (i.e.: left border's color of the embed); RGB integer, Hex (with prefix # (sharp)), namespaced string, and CSS colors string (e.g.: "rgb(32, 34, 37)") forms are acceptable. Exclusive namespaced strings:

Namespace Value Description
"Default" "#202225" / "rgb(32, 34, 37)" Default.
🍭 "Random" Random.
"Discord Blurple" "#5865F2" / "rgb(88, 101, 242)" Discord blurple.
"Discord Fuchsia" "#EB459E" / "rgb(254, 231, 92)" Discord fuchsia.
"Discord Green" "#57F287" / "rgb(87, 242, 135)" Discord green.
"Discord Red" "#ED4245" / "rgb(237, 66, 69)" Discord red.
"Discord Yellow" "#FEE75C" / "rgb(254, 231, 92)" Discord yellow.
"Embed Background Dark" "#2F3136" / "rgb(47, 49, 54)" Embed background in dark mode.

💡 Hint:

  • Alpha channel is not supported.
  • Namespaced strings are provided by meodai/color-names, maybe change and/or remove without any notification, use value instead except you want a random color.
embeds[*].footer

[Optional] <object> Footer of the embed.

embeds[*].footer.text

[Optional] <string> Footer text, up to 2048 characters.

embeds[*].footer.icon_url

[Optional] <string> Source URL of the footer icon, only supports HTTP, HTTPS, and attachments.

embeds[*].image

[Optional] <object> Image of the embed.

embeds[*].image.url

[Optional] <string> Source URL of the image, only supports HTTP, HTTPS, and attachments.

embeds[*].thumbnail

[Optional] <object> Thumbnail of the embed.

embeds[*].thumbnail.url

[Optional] <string> Source URL of the thumbnail, only supports HTTP, HTTPS, and attachments.

embeds[*].author

[Optional] <object> Author of the embed.

embeds[*].author.name

[Optional] <string> Author name, up to 256 characters.

embeds[*].author.url

[Optional] <string> Author URL.

embeds[*].author.icon_url

[Optional] <string> Source URL of the author icon, only supports HTTP, HTTPS, and attachments.

embeds[*].fields

[Optional] <object[]> Fields of the embed, up to 25 fields.

embeds[*].fields[*].name

[Optional] <string> Field name, up to 256 characters.

embeds[*].fields[*].value

[Optional] <string> Field value, up to 1024 characters.

embeds[*].fields[*].inline

[Optional] <boolean = false> Whether the field should display inline.

allowed_mentions

[Optional] <object> Allowed mentions for the message.

allowed_mentions.parse

[Optional] <string[]> Allowed mention types to parse from the content.

  • "roles": Control roles mentions.
  • "users": Control users mentions.
  • "everyone": Control @everyone and @here mentions.
allowed_mentions.roles

[Optional] <string[]> Allowed roles' IDs to mention, up to 100 IDs.

allowed_mentions.users

[Optional] <string[]> Allowed users' IDs to mention, up to 100 IDs.

files

[Optional] <string[] = []> Files as attachments of the message, which must be relative paths from GitHub Actions workspace, up to 8 MB and 10 files; At least one of the input payload.content, payload.embeds, or files must be provided.

wait

[Optional] <boolean = false> Whether to wait for Discord confirmation of message send before response, and returns the created message body. When this input is false, a message that is not saved does not return an error.

thread_type

[Optional] <string = "none"> Thread type of the message; Send to the specified thread within a webhook's channel.

  • "none": Not a thread. When this is defined, will ignore input thread_value.
  • "id": A created thread for message channel, the thread will automatically unarchive. When this is defined, input thread_value is require.
  • "name": A new thread for forum channel.

thread_value

🔐 [Optional] <string> Thread value of the message. When thread_type is:

truncate_enable

[Optional] <boolean = true> Whether to try truncate firstly when inputs are too large.

truncate_ellipsis

[Optional] <string = "..."> Ellipsis mark.

truncate_position

[Optional] <string = "end"> Ellipsis position.

  • "end": At the end of the string.
  • "middle": At the middle of the string.
  • "start": At the start of the string.

📤 Output

response

<string> Response content.

status_code

<number> Request status code.

status_ok

<boolean> Whether the request was successful.

status_text

<string> Request status text.

Example

Hello, world!

jobs:
  job_id:
    name: "Send Discord Webhook"
    runs-on: "ubuntu-latest"
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction@v5.0.0"
        with:
          key: "${{secrets.DISCORD_WEBHOOK_KEY}}"
          payload: |
            content: "Hello, world!"

birdie0

From birdie0's Discord Webhooks Guide.

jobs:
  job_id:
    name: "Send Discord Webhook"
    runs-on: "ubuntu-latest"
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction@v5.0.0"
        with:
          key: "${{secrets.DISCORD_WEBHOOK_KEY}}"
          payload: |
            {
              "username": "Webhook",
              "avatar_url": "https://i.imgur.com/4M34hi2.png",
              "content": "Text message. Up to 2000 characters.",
              "embeds": [
                {
                  "author": {
                    "name": "Birdie♫",
                    "url": "https://www.reddit.com/r/cats/",
                    "icon_url": "https://i.imgur.com/R66g1Pe.jpg"
                  },
                  "title": "Title",
                  "url": "https://google.com/",
                  "description": "Text message. You can use Markdown here. *Italic* **bold** __underline__ ~~strikeout~~ [hyperlink](https://google.com) `code`",
                  "color": 15258703,
                  "fields": [
                    {
                      "name": "Text",
                      "value": "More text",
                      "inline": true
                    },
                    {
                      "name": "Even more text",
                      "value": "Yup",
                      "inline": true
                    },
                    {
                      "name": "Use `\"inline\": true` parameter, if you want to display fields in the same line.",
                      "value": "okay..."
                    },
                    {
                      "name": "Thanks!",
                      "value": "You're welcome :wink:"
                    }
                  ],
                  "thumbnail": {
                    "url": "https://upload.wikimedia.org/wikipedia/commons/3/38/4-Nature-Wallpapers-2014-1_ukaavUI.jpg"
                  },
                  "image": {
                    "url": "https://upload.wikimedia.org/wikipedia/commons/5/5a/A_picture_from_China_every_day_108.jpg"
                  },
                  "footer": {
                    "text": "Woah! So cool! :smirk:",
                    "icon_url": "https://i.imgur.com/fKL31aD.jpg"
                  }
                }
              ]
            }

Example birdie0 Result

Guide

Discord

GitHub Actions