Monorepo for Aesthetic.Computer aesthetic.computer
at main 25 lines 783 B view raw
1#!/bin/bash 2 3WEBHOOK_URL=$DISCORD_WEBHOOK_URL # Define the Discord webhook URL 4COMMIT_URL="$REPOSITORY_URL/commit/$COMMIT_REF" 5 6# Get the last commit message and escape backticks 7COMMIT_MESSAGE=$(git log -1 --pretty=%B | sed 's/`/\\`/g') 8 9# Get the short hash 10SHORT_HASH="${COMMIT_REF:0:7}" 11 12# Create the Discord message 13DISCORD_MESSAGE="$COMMIT_MESSAGE ([$SHORT_HASH](<$COMMIT_URL>))" 14FLAGS="2" # Define the message flags (SUPPRESS_EMBEDS) 15 16# Use Python to generate a properly escaped JSON payload 17JSON_PAYLOAD=$(python -c " 18import json 19import sys 20message = sys.argv[1] 21print(json.dumps({'content': message, 'flags': $FLAGS})) 22" "$DISCORD_MESSAGE") 23 24# Send the POST request to the Discord webhook URL 25curl -H "Content-Type: application/json" -X POST -d "$JSON_PAYLOAD" $WEBHOOK_URL