/send-discord-webhook-ghaction

A GitHub Action to send a Discord webhook.

Primary LanguageJavaScriptOtherNOASSERTION

🌐 | English / δΈ­ζ–‡

Send Discord Webhook (GitHub Action)

SendDiscordWebhook.GitHubAction GitHub Contributors GitHub Issues GitHub Pull Requests GitHub Discussions GitHub Stars GitHub Forks GitHub Languages CodeFactor Grade LGTM Alerts LGTM Grade License

Release 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.

Previous named "[GitHub Action] Send To Discord".

🌟 Feature

  • Support attachments/files.
  • Support thread.

πŸ“š Documentation

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

🎯 Entrypoint / Target

Default (+default)

⚠ Important: This entrypoint is currently based to Docker (+docker), base can be changed between versions without announcement to ensure the stability.

jobs:
  job_id:
    runs-on: # Depend on the base requirement, recommended "ubuntu-________"
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction@<tag/version>"
Require Software

Depend on the base requirement.

Docker (+docker)

jobs:
  job_id:
    runs-on: "ubuntu-________"
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction/use-docker@<tag/version>"
Require Software
  • Docker

NodeJS (+nodejs)

⚠ Important: This entrypoint maybe need extra steps to manually setup NodeJS version.

jobs:
  job_id:
    runs-on: *any*
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction/use-nodejs@<tag/version>"
Require Software
  • NodeJS (>= v14.15.0) + NPM (>= v6.14.8)

πŸ“₯ 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 (Old)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^  Short (Old)

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 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> The message contents, 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> Override the default avatar of the webhook.

tts

[Optional] <boolean = false> Use TTS (Text To Speech).

embeds

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

  • embeds[*].title
  • embeds[*].description
  • embeds[*].footer.text
  • embeds[*].author.name
  • embeds[*].fields[*].name
  • embeds[*].fields[*].value
embeds[*].title

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

embeds[*].description

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

embeds[*].url

[Optional] <string> URL of embed.

embeds[*].timestamp

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

embeds[*].color

[Optional] <(number | string) = 2105893> Color of the embed (i.e.: left border's color of embed); Decimal (integer / RGB integer), Hex (6 digits, with prefix # (sharp)), namespaced string, and RGB string (split with , (comma)) forms are acceptable.

Decimal Hex Namespace RGB
Black 0 "#000000" "black" "0,0,0"
Default 2105893 "#202225" "default" "32,34,37"
Discord Black 2303786 "#23272A" "discordblack" "35,39,42"
Discord Dark 2895667 "#2C2F33" "discorddark" "44,47,51"
Embed Background (Dark Mode) 3092790 "#2F3136" "embeddark" "47,49,54"
Discord Blue Purple 7506394 "#7289DA" "discordblurple" "114,137,218"
Discord Gray/Grey Purple 10070709 "#99AAB5" "discordgrayple" / "discordgreyple" "153,170,181"
White 16777215 "#FFFFFF" "white" "255,255,255"
Random "random"
embeds[*].footer

[Optional] <object> Footer of embed.

embeds[*].footer.text

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

embeds[*].footer.icon_url

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

embeds[*].image

[Optional] <object> Image of embed.

embeds[*].image.url

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

embeds[*].thumbnail

[Optional] <object> Thumbnail of embed.

embeds[*].thumbnail.url

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

embeds[*].author

[Optional] <object> Author of embed.

embeds[*].author.name

[Optional] <string> Name of author, up to 256 characters.

embeds[*].author.url

[Optional] <string> URL of author.

embeds[*].author.icon_url

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

embeds[*].fields

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

embeds[*].fields[*].name

[Optional] <string> Name of field, up to 256 characters.

embeds[*].fields[*].value

[Optional] <string> Value of field, up to 1024 characters.

embeds[*].fields[*].inline

[Optional] <boolean = false> Field should display inline or not.

allowed_mentions

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

allowed_mentions.parse

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

  • "roles": Controls role mentions.
  • "users": Controls user mentions.
  • "everyone": Controls @everyone and @here mentions.
allowed_mentions.roles

[Optional] <string[]> Roles ID to mention, up to 100 IDs.

allowed_mentions.users

[Optional] <string[]> Users ID to mention, up to 100 IDs.

files

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

threadid

πŸ” [Optional] <string> Thread ID; Send to the specified thread within a webhook's channel, the thread will automatically be unarchived.

wait

[Optional] <boolean = false> 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.

truncate_enable

[Optional] <boolean = true> When input payload is too large, try to prune/trim/truncate first.

truncate_ellipsis

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

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.

dryrun

[Optional] <boolean = false> Dry run; For debug use.

πŸ“€ Output

N/A

Example

Hello, world!

jobs:
  job_id:
    name: "Send Discord Webhook"
    runs-on: "ubuntu-latest"
    steps:
      - uses: "hugoalh/send-discord-webhook-ghaction@v4.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@v4.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