Update main.py #16
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 # 使用 Linux 环境 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # 更新到 v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 # 保持 v4 | |
with: | |
python-version: 'latest' # 使用最新版 Python | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Run script | |
run: python main.py # 在 Linux 中直接使用 python | |
- name: Upload results | |
uses: actions/upload-artifact@v4 # 更新到 v4 | |
with: | |
name: txt-files | |
path: '*.txt' |