Skip to content

Notify Discord on Push #3

Notify Discord on Push

Notify Discord on Push #3

name: Notify Discord on Push
on: [push]
jobs:
discordNotification:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Debug GITHUB_EVENT_PATH
run: |
echo "Inspecting GITHUB_EVENT_PATH:"
cat $GITHUB_EVENT_PATH
- name: Send message to Discord
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH:-/github/workflow/event.json}
# Extract commit message, URL, and repository name
COMMIT_MESSAGE=$(jq -r '.head_commit.message // "No commit message"' < "$GITHUB_EVENT_PATH")
COMMIT_URL=$(jq -r '.head_commit.url // "No commit URL"' < "$GITHUB_EVENT_PATH")
REPO_NAME=$(jq -r '.repository.full_name // "Unknown repository"' < "$GITHUB_EVENT_PATH")
MESSAGE="-# New Update on Dev Version:\n${COMMIT_MESSAGE}\n-# [View Code](<${COMMIT_URL}>)"
curl -H "Content-Type: application/json" \
-X POST \
-d "{\"content\": \"$MESSAGE\"}" \
"$DISCORD_WEBHOOK_URL"