feat: mcp-v1.0.3 新增日期解析工具,增加 mcp 使用文档英文版,增强 github 推送的稳定性

This commit is contained in:
sansan
2025-11-26 19:43:01 +08:00
parent 39738cc821
commit c02e5cb55f
9 changed files with 1062 additions and 85 deletions
+51 -16
View File
@@ -1,51 +1,52 @@
name: Hot News Crawler
on:
schedule:
# 我们使用的是 github 官方提供的资源来进行的推送,而每个账号的资源是限额的,为了不被官方判定为滥用而面临封号的风险,不建议比半小时更低
- cron: "0 * * * *" # 每小时整点运行一次(实际有偏差) 或者 "*/30 * * * *" (每半小时执行一次) 或者 "*/30 0-14 * * *"(每天早上 8 点到晚上 10 点期间,每半小时运行一次)
- cron: "0 * * * *"
workflow_dispatch:
# 添加权限设置
concurrency:
group: crawler-main-branch
cancel-in-progress: true
permissions:
contents: write
jobs:
crawl:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: main
fetch-depth: 0
clean: true
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Verify required files
run: |
echo "🔍 检查必需的配置文件..."
if [ ! -f config/config.yaml ]; then
echo "❌ 错误: config/config.yaml 文件不存在"
echo "请参考项目文档创建配置文件"
exit 1
fi
if [ ! -f config/frequency_words.txt ]; then
echo "❌ 错误: config/frequency_words.txt 文件不存在"
echo "请参考项目文档创建频率词配置文件"
exit 1
fi
echo "✅ 配置文件检查通过"
- name: Run crawler
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
@@ -66,10 +67,44 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
GITHUB_ACTIONS: true
run: python main.py
- name: Commit and push if changes
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
echo "🔄 Syncing with remote..."
git fetch origin main
# 保存当前更改
git stash --include-untracked || echo "Nothing to stash"
# 同步到远程最新
git reset --hard origin/main
# 恢复本次更改
git stash pop || echo "Nothing to pop"
git add -A
git diff --quiet && git diff --staged --quiet || (git commit -m "Auto update by GitHub Actions at $(TZ=Asia/Shanghai date)" && git push)
if git diff --quiet && git diff --staged --quiet; then
echo "📭 No changes to commit"
exit 0
fi
echo "📝 Committing changes..."
TIMESTAMP=$(TZ=Asia/Shanghai date "+%Y-%m-%d %H:%M:%S")
git commit -m "Auto update by GitHub Actions at $TIMESTAMP"
echo "⬆️ Pushing changes with retry..."
for i in {1..5}; do
git pull --rebase origin main && git push origin main && {
echo "✅ Successfully pushed on attempt $i"
exit 0
}
echo "⚠️ Attempt $i/$i failed, waiting $((i*3)) seconds..."
sleep $((i * 3))
done
echo "❌ Failed to push after 5 attempts"
exit 1