name: Daily Trends Factory on: schedule: # 每天 UTC 18:00 运行 (北京时间凌晨 02:00) - cron: '0 18 * * *' workflow_dispatch: permissions: contents: write jobs: update-trends: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Execute Trends Engine run: python scripts/fetch_trends.py - name: Commit and Push run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add data/keywords/ # 防御机制:如果没有新数据,就静默退出,不产生空提交 if git diff --staged --quiet; then echo "No changes, skipping." exit 0 fi # 策略:放弃危险的 amend 强制覆盖,采用带日期的标准安全提交 git commit -m "chore(data): 🤖 自动机兵:刷新全战区热点词库 [$(date +'%Y-%m-%d')]" git push origin main