#!/bin/bash # OpenClaw Daily Digest - Full Pipeline # This script runs the complete digest generation and delivery pipeline set -e # Exit on error WORKSPACE="/home/openclaw/.openclaw/workspace/automations/openclaw-digest" OUTPUT_DIR="$WORKSPACE/output" LOG_FILE="$OUTPUT_DIR/pipeline.log" # Create output directory if needed mkdir -p "$OUTPUT_DIR" # Logging function log() { echo "[$(date '+%Y-%m-%d %H:%M:%S UTC')] $1" | tee -a "$LOG_FILE" } log "🦀 Starting OpenClaw Daily Digest Pipeline" log "================================================" # Step 1: Aggregate content log "Step 1: Aggregating content..." cd "$WORKSPACE" if python3 aggregate.py 24 "$OUTPUT_DIR/digest.json" >> "$LOG_FILE" 2>&1; then log "✅ Content aggregation complete" else log "❌ Content aggregation failed" exit 1 fi # Step 2: Generate and send email log "Step 2: Generating and sending email..." RECIPIENT="${1:-anthony@martinwa.org}" SENDER="${2:-krillyclaw@gmail.com}" if python3 send_digest.py "$OUTPUT_DIR/digest.json" "$RECIPIENT" "$SENDER" >> "$LOG_FILE" 2>&1; then log "✅ Email sent successfully to $RECIPIENT" else log "❌ Email sending failed" exit 1 fi log "================================================" log "🎉 Daily digest pipeline completed successfully!" # Cleanup old log files (keep last 7 days) find "$OUTPUT_DIR" -name "pipeline.log.*" -mtime +7 -delete 2>/dev/null || true exit 0