diff --git a/.github/workflows/update-date.yml b/.github/workflows/update-date.yml new file mode 100644 index 0000000..be3c891 --- /dev/null +++ b/.github/workflows/update-date.yml @@ -0,0 +1,40 @@ +name: Update Date + +on: + schedule: + - cron: '0 0 * * *' # 每天午夜 (UTC) 运行一次 + push: + branches: + - main # 也可以在推送到主分支时触发 + +jobs: + update-date: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run the update script + run: | + python update_date.py + + - name: Commit and push changes + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + git add date_config.json + git commit -m "Update date to $(date +'%Y-%m-%d')" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}