Files
huggingface-daily-paper-feed/cron_update.sh

50 lines
1.6 KiB
Bash

#!/bin/bash
set -euo pipefail
# ─────────────────────────────────────────────
# cron_update.sh — run daily via cron
# ─────────────────────────────────────────────
# 1. Generate RSS feeds
# 2. Commit & push updated feeds to Gitea
#
# Designed for Hermes cron or system cron.
# ─────────────────────────────────────────────
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$REPO_DIR"
# Setup Python
PYTHON=$(command -v python3 || command -v python)
# Try venv first, fallback to system python
if [[ -f .venv/bin/python ]]; then
PYTHON=".venv/bin/python"
fi
# Verify deps installed
echo "[cron] Using: $PYTHON ($($PYTHON --version))"
# Generate feeds (save in repo root — Gitea raw URL serves directly)
echo "[cron] Generating RSS feeds..."
$PYTHON run.py --output-dir "$REPO_DIR"
# Git commit & push if feed files changed
cd "$REPO_DIR"
CHANGED=false
for f in feed.xml feed_weekly.xml feed_monthly.xml; do
if [[ -f "$f" ]]; then
git add "$f" && CHANGED=true
fi
done
if $CHANGED && ! git diff --cached --quiet; then
echo "[cron] Changes detected — committing and pushing..."
git commit -m "bot: update RSS feeds $(date '+%Y-%m-%d')"
git push origin main
echo "[cron] ✅ Pushed updated feeds to Gitea."
else
echo "[cron] No changes to feeds."
fi
echo "[cron] Done."