#!/bin/bash # Cron wrapper for GitHub notifications # 1. Auto-dismisses low-value notifications (nightlies, previews, empty releases) # 2. Checks remaining notifications and formats for human consumption set -e WORKSPACE="${WORKSPACE:-/home/node/.openclaw/workspace}" cd "$WORKSPACE" # First: auto-dismiss low-value notifications bash skills/github-notifications/scripts/auto-dismiss.sh >/dev/null 2>&1 || true # Then: run the checker RESULT=$(bash skills/github-notifications/scripts/check.sh) # Check for errors if echo "$RESULT" | jq -e '.error' > /dev/null 2>&1; then ERROR_MSG=$(echo "$RESULT" | jq -r '.error') ERROR_DETAILS=$(echo "$RESULT" | jq -r '.details') echo "❌ **GitHub Check Failed**" echo "" echo "Error: $ERROR_MSG" echo "\`\`\`" echo "$ERROR_DETAILS" | head -20 echo "\`\`\`" exit 0 fi # Check if there's new activity HAS_NEW=$(echo "$RESULT" | jq -r '.hasNew') if [ "$HAS_NEW" != "true" ]; then # Nothing new - stay completely silent (no output = no message) exit 0 fi # Format and output the summary echo "🔔 **GitHub Activity Update**" echo "" # Process PRs PR_COUNT=$(echo "$RESULT" | jq '.newPRs | length') if [ "$PR_COUNT" -gt 0 ]; then echo "**Pull Requests ($PR_COUNT new):**" echo "$RESULT" | jq -r '.newPRs[] | "- **\(.repo)** #\(.title)\n Updated: \(.updated) | Reason: \(.reason)"' echo "" fi # Process Releases RELEASE_COUNT=$(echo "$RESULT" | jq '.newReleases | length') if [ "$RELEASE_COUNT" -gt 0 ]; then echo "**Releases ($RELEASE_COUNT new):**" while IFS= read -r rel; do repo=$(echo "$rel" | jq -r '.repo') title=$(echo "$rel" | jq -r '.title') updated=$(echo "$rel" | jq -r '.updated') echo "- **$repo** \`$title\`" echo " Released: $updated" # Best-effort major changes summary from release body. # Use the release API URL directly from notifications/checker output when available. release_url=$(echo "$rel" | jq -r '.url // empty') body="" if [ -n "$release_url" ]; then body=$(gh api "$release_url" --jq '.body' 2>/dev/null || true) fi # Fallback only if direct release lookup failed and title might actually equal tag. if [ -z "$body" ] || [ "$body" = "null" ]; then tag_encoded=$(jq -nr --arg s "$title" '$s|@uri') body=$(gh api "repos/$repo/releases/tags/$tag_encoded" --jq '.body' 2>/dev/null || true) fi if [ -n "$body" ] && [ "$body" != "null" ]; then summary=$(printf '%s\n' "$body" \ | sed 's/\r$//' \ | awk 'NF' \ | grep -E '^(\- |\* |[0-9]+\.|## |### )' \ | head -3 \ | sed 's/^/ /') if [ -z "$summary" ]; then summary=$(printf '%s\n' "$body" | awk 'NF{print; exit}' | cut -c1-240) [ -n "$summary" ] && summary=" $summary" fi if [ -n "$summary" ]; then echo " Major changes:" echo "$summary" fi else echo " Major changes: release details unavailable from GitHub API." fi done < <(echo "$RESULT" | jq -c '.newReleases[]') fi