简体   繁体   中英

How do I simply run a python script from github repo with actions

I assume it's possible to schedule a python script to run every day for example, from my github repository.

After searching, I've come up with the following main.yml file that resides in the master branch of the repo:

the.py file I want to run resides in another branch; I suppose it doesn't have to if it causes an issue, but the script isn't running either way.

I'm new to a lot of this, and have a funny feeling I'm missing fundamental pieces to get this working.

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

Everything seems to be working now, the solution was to move my main.yml file into.github/workflows; and I opted for moving my_file.py from alternate branch into the master branch.
Although one helpful comment recommends specifying the ref branch where you run my_file.py if my_file.py is not located in the default branch.

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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