每日AI动态更新 V2 #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 每日AI动态更新 V2 | |
| on: | |
| schedule: | |
| # 每天北京时间早上8点运行 (UTC 00:00) | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: # 允许手动触发 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-daily-ai: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出代码 | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.MY_GITHUB_TOKEN }} | |
| - name: 设置Python环境 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: 安装依赖 | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r scripts/requirements.txt | |
| echo "============================================" | |
| echo "已安装的包:" | |
| pip list | grep -E "(google-generativeai|openai|perplexity)" | |
| echo "============================================" | |
| - name: 诊断 API 连接 | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }} | |
| run: | | |
| echo "运行诊断脚本..." | |
| python scripts/diagnose_gemini.py || true | |
| - name: 运行AI动态收集脚本 V2 | |
| env: | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }} | |
| GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | |
| HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }} | |
| # ai_news_collector_lib 需要的环境变量 | |
| NEWS_API_KEY: ${{ secrets.NEWS_API_KEY }} | |
| TAVILY_API_KEY: ${{ secrets.TAVILY_API_KEY }} | |
| GOOGLE_SEARCH_API_KEY: ${{ secrets.GOOGLE_SEARCH_API_KEY }} | |
| GOOGLE_SEARCH_ENGINE_ID: ${{ secrets.GOOGLE_SEARCH_ENGINE_ID }} | |
| SERPER_API_KEY: ${{ secrets.SERPER_API_KEY }} | |
| BRAVE_SEARCH_API_KEY: ${{ secrets.BRAVE_SEARCH_API_KEY }} | |
| METASOSEARCH_API_KEY: ${{ secrets.METASOSEARCH_API_KEY }} | |
| run: | | |
| echo "============================================" | |
| echo "开始收集每日AI动态 (V2)" | |
| echo "============================================" | |
| python scripts/daily_ai_collector_v2.py | |
| echo "============================================" | |
| echo "收集完成" | |
| echo "============================================" | |
| - name: 检查生成的文件 | |
| run: | | |
| echo "生成的文件:" | |
| ls -lh content/zh/daily_ai/ | tail -5 | |
| echo "" | |
| echo "最新文件内容预览:" | |
| latest_file=$(ls -t content/zh/daily_ai/*.md | head -1) | |
| head -50 "$latest_file" | |
| - name: 提交更改 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git | |
| git add content/zh/daily_ai/ | |
| git diff --staged --quiet || git commit -m "🤖 自动更新每日AI动态 V2 - $(date '+%Y-%m-%d')" | |
| git push origin main |