31 lines
1009 B
Bash
Executable File
31 lines
1009 B
Bash
Executable File
#!/bin/bash
|
|
# Daily digest cron wrapper
|
|
# Run daily at 14:00 UTC (22:00 Beijing)
|
|
|
|
set -e
|
|
|
|
PROJECT_DIR="$HOME/inspiration-collector"
|
|
LOG_FILE="$PROJECT_DIR/ai-insights/logs/daily_digest.log"
|
|
|
|
mkdir -p "$(dirname "$LOG_FILE")"
|
|
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting daily digest..." >> "$LOG_FILE"
|
|
|
|
cd "$PROJECT_DIR"
|
|
python3 analyzers/daily_digest.py >> "$LOG_FILE" 2>&1
|
|
|
|
# Git sync: pull rebase first, then always push
|
|
cd "$PROJECT_DIR"
|
|
git pull --rebase origin main >> "$LOG_FILE" 2>&1 || echo "WARNING: rebase failed, continuing..." >> "$LOG_FILE"
|
|
|
|
# Check if anything to commit
|
|
if [[ -n $(git status --porcelain ai-insights/) ]]; then
|
|
git add ai-insights/
|
|
git commit -m "daily digest $(date '+%Y-%m-%d')"
|
|
fi
|
|
|
|
# Always push (covers both new commits and rebased pending commits)
|
|
git push origin main >> "$LOG_FILE" 2>&1 && echo "Pushed to Gitea successfully" >> "$LOG_FILE" || echo "WARNING: push failed" >> "$LOG_FILE"
|
|
|
|
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Daily digest done." >> "$LOG_FILE"
|