Let it be

Friday, January 12, 2024

Run cron schedule job on Github Actions



1. Create a project at Github

2. Create your all python programs at this project, or import your python programs

3. Creaet a new .github folder(P.S. there's a "." period prefix )

4. At .github folder, create a yaml file

5. After press "Commit Change", the cron job will run on your schedule.

(P.S. the time is based on UTC time zone)


yaml sample file

name: Github crontab action demo

on:

  schedule:

    - cron: '0 6,21 * * *'

jobs: 

  Explorer-Github-Actions:

    runs-on: ubuntu-latest

    steps:

      - name: Checkout

        uses: actions/checkout@v4

      - name: Setup Python Version

        uses: actions/setup-python@v2

        with:

          python-version: 3.11 # Install the python version needed


      - name: Install Python dependencies

        run: pip install -r requirements.txt

      - name: get stock price

        run:

          python3 dyudaily.py

      - name: List files on the folder 002

        run:

          ls ${{ github.workspace }}




0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home