繁体   English   中英

我如何简单地从 github 回购中运行 python 脚本并执行操作

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM