Run Python Script #8
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: Run Python Script | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- main.py # 当 main.py 变动时触发 | |
schedule: | |
- cron: '0 */6 * * *' # 每隔 6 小时运行一次 | |
workflow_dispatch: # 允许手动触发工作流 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # 更新到 v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 # 保持 v4,适用于 Node.js 20 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run script | |
run: python main.py | |
- name: Upload results | |
uses: actions/upload-artifact@v4 # 更新到 v4 | |
with: | |
name: txt-files | |
path: '*.txt' |