ci(workflows): 🔧 修复 Actions 推送逻辑,适配 main 分支保护规则

This commit is contained in:
hotyue
2026-04-13 08:27:33 +00:00
parent c657c92b27
commit 7e9da4b82a

View File

@@ -26,24 +26,19 @@ jobs:
- name: Execute Trends Engine - name: Execute Trends Engine
run: python scripts/fetch_trends.py run: python scripts/fetch_trends.py
- name: Commit and Force Push - name: Commit and Push
run: | run: |
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add data/keywords/ git add data/keywords/
# 防御机制:如果没有新数据,就静默退出,不产生空提交
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes, skipping." echo "No changes, skipping."
exit 0 exit 0
fi fi
# 策略:如果上一次是机器人提交的,就直接覆盖它 # 策略:放弃危险的 amend 强制覆盖,采用带日期的标准安全提交
LAST_AUTHOR=$(git log -1 --format='%an') git commit -m "chore(data): 🤖 自动机兵:刷新全战区热点词库 [$(date +'%Y-%m-%d')]"
if [ "$LAST_AUTHOR" = "github-actions[bot]" ]; then git push origin main
git commit --amend -m "chore(data): 🤖 自动机兵:刷新全战区热点词库 [v3.3.0 OTA]"
else
git commit -m "chore(data): 🤖 自动机兵:刷新全战区热点词库 [v3.3.0 OTA]"
fi
git push --force origin main