Update Date in README #552
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 Date in README | |
| # 触发条件 | |
| on: | |
| workflow_dispatch: | |
| # 定时触发 | |
| schedule: | |
| # 每12小时获取一次 | |
| - cron: '0 */12 * * *' | |
| jobs: | |
| update-date: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the repository | |
| uses: actions/checkout@v3 | |
| - name: Update date in README.md | |
| run: | | |
| # 获取当前日期,格式为 YYYY-MM-DD | |
| current_date=$(date +'%Y-%m-%d') | |
| # 使用 sed 替换 README.md 中的日期(顶部) | |
| sed -i "1s/更新时间 .*/更新时间 $current_date/" README.md | |
| # 输出文件内容以便调试 | |
| cat README.md | |
| - name: Check if README.md is changed | |
| run: | | |
| git diff README.md | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.name 'tfyytvu' | |
| git config --global user.email 'ytguvgb@ctyvub.hujh' | |
| # 检查是否有变动 | |
| git diff --quiet || git commit -am "Update date in README.md to $current_date" | |
| git push |