main.yml 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. name: Daily Update
  2. on:
  3. schedule:
  4. - cron: '45 21 * * *'
  5. workflow_dispatch:
  6. branches:
  7. - main
  8. jobs:
  9. run_script:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - name: Checkout repository
  13. uses: actions/checkout@v2
  14. - name: Set up Python
  15. uses: actions/setup-python@v2
  16. with:
  17. python-version: '3.10'
  18. - name: Cache dependencies
  19. uses: actions/cache@v2
  20. with:
  21. path: ~/.cache/pip
  22. key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
  23. restore-keys: |
  24. ${{ runner.os }}-pip-
  25. - name: Install dependencies
  26. run: |
  27. pip install requests
  28. - name: Run Python script
  29. run: python main.py
  30. - name: Commit and push if changed
  31. run: |
  32. git config --local user.email "github-actions[bot]@users.noreply.github.com"
  33. git config --local user.name "github-actions[bot]"
  34. git add -A
  35. if ! git diff --staged --quiet; then
  36. git commit -m "Auto-update live files"
  37. git push
  38. fi
  39. env:
  40. TZ: Asia/Shanghai