Daily AI Knowledge Collection #104
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: Daily AI Knowledge Collection | |
| on: | |
| schedule: | |
| # 错峰:避开 UTC 整点(尤其午夜)这个最拥堵的时段, | |
| # 否则定时任务常被 GitHub 延迟数小时甚至直接丢弃。 | |
| - cron: "23 18 * * *" # UTC 18:23 = 北京时间次日 02:23 | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| collect: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: pyproject.toml | |
| - name: Install dependencies | |
| run: | | |
| pip install -e . | |
| - name: Run collection pipeline | |
| env: | |
| LLM_API_URL: ${{ secrets.LLM_API_URL }} | |
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | |
| LLM_MODEL: ${{ secrets.LLM_MODEL }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| KNOWLEDGE_DIR: ./knowledge | |
| run: | | |
| python -m app.main crawl --knowledge-dir ./knowledge | |
| - name: Build static site | |
| run: | | |
| python3 scripts/build_static.py ./knowledge ./site/data | |
| - name: Commit and push results | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add knowledge/ site/data/ | |
| if git diff --staged --quiet; then | |
| echo "No new articles to commit" | |
| else | |
| FILE_COUNT=$(git diff --staged --name-only | grep -c '\.md$' || true) | |
| git commit -m "chore: daily collection - ${FILE_COUNT} articles [$(date -u +%Y-%m-%d)]" | |
| git push | |
| fi |