name: "Discord Webhook" description: "Send a message to Discord via webhook using curl" inputs: webhook_url: description: "Discord webhook URL" required: true message: description: "Message to send" required: true username: description: "Override the default username of the webhook" required: false default: "" avatar_url: description: "Override the default avatar of the webhook" required: false default: "" color: description: "Embed color (decimal number)" required: false default: "" runs: using: "composite" steps: - name: Send Discord notification shell: bash run: | if [ -n "${{ inputs.color }}" ]; then # Send as embed with color PAYLOAD=$(jq -n \ --arg content "${{ inputs.message }}" \ --arg username "${{ inputs.username }}" \ --arg avatar "${{ inputs.avatar_url }}" \ --arg color "${{ inputs.color }}" \ '{ content: (if $content != "" then $content else null end), username: (if $username != "" then $username else null end), avatar_url: (if $avatar != "" then $avatar else null end), embeds: (if $color != "" then [{description: $content, color: ($color | tonumber)}] else null end) } | with_entries(select(.value != null))') else # Send as simple message PAYLOAD=$(jq -n \ --arg content "${{ inputs.message }}" \ --arg username "${{ inputs.username }}" \ --arg avatar "${{ inputs.avatar_url }}" \ '{ content: $content, username: (if $username != "" then $username else null end), avatar_url: (if $avatar != "" then $avatar else null end) } | with_entries(select(.value != null))') fi curl -H "Content-Type: application/json" \ -d "$PAYLOAD" \ "${{ inputs.webhook_url }}"