#!/bin/sh # notify.sh -- post a short message to the Discord webhook in ~/.config/radiance-bench.env # (DISCORD_WEBHOOK_URL), for anything in the SYCL port that needs the user's attention: a blocker, # a question, a finished milestone. The URL is a secret: it is read from the file, never printed. # # Usage: scripts/sycl/notify.sh "message" (cut to Discord's 2000 characters) # Exit status: 0 posted, 1 no webhook configured, 2 the post failed (HTTP status printed). set -e msg=${1:?usage: notify.sh "message"} env_file=${RAD_BENCH_ENV:-$HOME/.config/radiance-bench.env} [ -r "$env_file" ] && . "$env_file" if [ -z "$DISCORD_WEBHOOK_URL" ]; then echo "notify.sh: no DISCORD_WEBHOOK_URL (looked in $env_file); not posted" >&2 exit 1 fi payload=$(printf '%s' "$msg" | jq -Rs '{content: (.[0:2000])}') code=$(printf '%s' "$payload" | curl -sS -o /dev/null -w '%{http_code}' \ -H 'Content-Type: application/json' --data-binary @- "$DISCORD_WEBHOOK_URL") || code=000 case "$code" in 2??) exit 0 ;; *) echo "notify.sh: the webhook answered HTTP $code" >&2; exit 2 ;; esac