Why my github action's cron is not working?
Asked Answered
E

2

5

I have written a github actions workflow yml file to schedule a job to run everyday at a particular time but it's not working. I have even used the cron written in official doc but still it is not working. Is it due to Indian TimeZone or some other reason??

name: run app.py

on:
  schedule:
    - cron: '30 4,17 * * *'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        
      - name: setup python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9' # install the python version needed
          
      - name: install python packages
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          
      - name: execute py script # run main.py
        env:
          DSA_SHEET: ${{ secrets.DSA_SHEET }}
        run: python app.py

I have tried to change the cron many time but it was not working. It was only working when set to run every 5mins but when I set it to run everyday it is not working.

Editorial answered 19/12, 2022 at 12:30 Comment(0)
M
7

Github actions schedule is in UTC time.

https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule

Mammiemammiferous answered 19/12, 2022 at 12:58 Comment(0)
P
0

Actually, GitHub actions are scheduled in UTC time, which is different from your Indian Time Zone. An alternative could be to make the time shift manually and configure your CRON with the equivalent UTC time.

For example, if the difference is 5 hours and 30 minutes, your configuration could be:

on:
  schedule:
    - cron: '00 23,11 * * *'

Unfortunately, according to this GitHub discussion, time zone configuration is not yet allowed in actions, despite the numbers of requests.

Prowel answered 21/10 at 19:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.