Scheduled Python Worker #41
This file contains 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: Scheduled Python Worker | |
on: | |
schedule: | |
- cron: '0 20 * * *' # 每天 UTC 时间 00:00 运行 | |
workflow_dispatch: # 添加手动触发器 | |
jobs: | |
run-worker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' # 选择你想要的 Python 版本 | |
- name: Install Dependencies | |
run: pip install packaging requests # 安装 requests 库 | |
- name: Run Python Script | |
run: python worker.py | |
- name: Check if there are any changes | |
id: verify_diff | |
run: | | |
git diff --quiet plugins.json || echo "changed=true" >> $GITHUB_OUTPUT | |
- name: Commit | |
if: steps.verify_diff.outputs.changed == 'true' | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
git add plugins.json | |
git commit -m "Update plugins.json" | |
- name: Push | |
if: steps.verify_diff.outputs.changed == 'true' | |
run: git push |