Repository Maintenance #41
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: Repository Maintenance | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # 每天午夜运行 | |
| workflow_dispatch: # 允许手动触发 | |
| push: | |
| branches: [ master ] | |
| paths: | |
| - 'categories/*.md' | |
| - 'README.md' | |
| - 'scripts/*.py' | |
| jobs: | |
| maintain: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Install dependencies | |
| run: pip install requests | |
| - name: Run Maintenance Script | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: python scripts/maintain_repo.py | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add . | |
| git diff --quiet && git diff --staged --quiet || git commit -m "chore: automated repository maintenance (stars, links, metadata)" | |
| git pull --rebase origin master | |
| git push |