Update Date in README #122
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: | |
# 每6小时获取一次 | |
- 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 "s/更新时间 .*/更新时间 $current_date/" README.md | |
- name: Commit and push changes | |
run: | | |
git config --global user.name 'nodesfree' | |
git config --global user.email '[email protected]' | |
git add README.md | |
git commit -m "Update date in README.md to $current_date" | |
git push |