Keep Repo Active #347
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: Keep Repo Active | |
| on: | |
| schedule: | |
| # 每天 UTC 00:00(北京时间 08:00)运行 | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: # 允许手动触发 | |
| permissions: # 赋予写入权限 | |
| contents: write | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Update README with precise time | |
| run: | | |
| # 获取当前时间(精确到秒,格式:YYYY-MM-DD HH:MM:SS) | |
| CURRENT_TIME=$(date +'%Y-%m-%d %H:%M:%S') | |
| # 修改 README.md 的最后一行 | |
| sed -i "\$s/.*/Last updated: $CURRENT_TIME/" README.md | |
| # 提交更改 | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| git add README.md | |
| git commit -m "Update README with precise time" | |
| git push |