27 lines
1.4 KiB
Bash
Executable file
27 lines
1.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Weekly newsletter draft generator. Runs from the local repo so it can use the
|
|
# admin signer in ~/.config/skatespots/zsp.env and the git/release-notes context.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
if [ -d "$HOME/.nvm/versions/node" ]; then
|
|
NODE_BIN="$(ls -d "$HOME"/.nvm/versions/node/*/bin 2>/dev/null | sort -V | tail -1)"
|
|
[ -n "$NODE_BIN" ] && export PATH="$NODE_BIN:$PATH"
|
|
fi
|
|
|
|
OUT="$(npx tsx scripts/newsletter-weekly.ts)"
|
|
printf '%s\n' "$OUT"
|
|
|
|
# Let the admins know a draft is waiting. This is a content-free NIP-17 DM; the
|
|
# push service wakes their phones, and the message contains only the issue
|
|
# number and the /newsletter URL. A failed notice must never fail the draft.
|
|
META="$(printf '%s' "$OUT" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{try{const j=JSON.parse(s);process.stdout.write([j.issue,j.autoPublished===true?'published':'draft'].join(':'))}catch{process.stdout.write('')}})")"
|
|
NUMBER="${META%%:*}"
|
|
MODE="${META##*:}"
|
|
if [ -n "$NUMBER" ]; then
|
|
if [ "$MODE" = "published" ]; then
|
|
MSG="Weekly newsletter #${NUMBER} is published: https://skate-spots.org/newsletter"
|
|
else
|
|
MSG="Weekly newsletter draft #${NUMBER} is ready for review: https://skate-spots.org/newsletter (admin banner → Load draft). Nothing is public until you publish."
|
|
fi
|
|
scripts/send-ops-alert.sh "$MSG" >/dev/null 2>&1 || true
|
|
fi
|