Skip to content

Update README.md

Update README.md #39

name: Discord Commit Notifications
on:
push:
branches:
- '**'
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Discord Embed
run: |
MESSAGE=$(jq -r '.head_commit.message // .commits[0].message' "$GITHUB_EVENT_PATH")
AUTHOR=$(jq -r '.head_commit.author.name // "Unknown"' "$GITHUB_EVENT_PATH")
URL=$(jq -r '.head_commit.url // .commits[0].url' "$GITHUB_EVENT_PATH")
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
jq -n \
--arg message "$MESSAGE" \
--arg author "$AUTHOR" \
--arg url "$URL" \
--arg branch "${{ github.ref_name }}" \
--arg sha "$SHORT_SHA" \
'{
thread_name: ("Commit: " + $message),
embeds: [{
author: {
name: $author,
icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
},
title: ("**Message:** " + $message),
description: ("**Branch:** " + $branch),
fields: [
{ name: "View on Github", value: ("[Link](" + $url + ")"), inline: false },
{ name: "Commit", value: $sha, inline: false }
],
color: 3066993
}]
}' \
| curl -X POST -H "Content-Type: application/json" \
--data @- \
${{ secrets.DISCORD_WEBHOOK_COMMIT_URL }}