[英]How do I simply run a python script from github repo with actions
我假設可以安排一個 python 腳本每天運行,例如,從我的 github 存儲庫。
搜索后,我想出了以下 main.yml 文件,該文件位於 repo 的 master 分支中:
我要運行的 .py 文件位於另一個分支中; 我想如果它引起問題就不必這樣做,但是腳本沒有以任何方式運行。
我對這方面的很多東西都很陌生,並且有一種有趣的感覺,我缺少基本的部分來使其正常工作。
name: py
on:
schedule:
- cron: "30 11 * * *" #runs at 11:30 UTC everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2 # checkout the repository content to github runner.
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
ref: # branch
my_other_branch
- name: execute py script # run file
run: |
python my_file.py
現在一切似乎都在工作,解決方案是將我的 main.yml 文件移動到 .github/workflows; 我選擇將 my_file.py 從備用分支移動到主分支。
盡管如果 my_file.py 不在默認分支中,一條有用的評論建議指定運行 my_file.py 的 ref 分支。
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.