Update Papers Daily #56
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: Update Papers Daily | |
| on: | |
| # 每天 UTC 0:00 自动运行 | |
| schedule: | |
| - cron: '0 0 * * *' | |
| # 支持手动触发 | |
| workflow_dispatch: | |
| # Push 到 main 分支时触发 | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| update-papers: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - 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: Fetch papers | |
| run: | | |
| python scripts/fetch_papers.py | |
| - name: Generate HTML | |
| run: | | |
| python scripts/generate_html.py | |
| - name: Commit and push if changed | |
| run: | | |
| git config --local user.name 'github-actions[bot]' | |
| git config --local user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add data/papers*.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Auto update papers - $(date +'%Y-%m-%d')" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs | |
| publish_branch: gh-pages | |
| force_orphan: true |