17

I have a Github Actions workflow that is triggered every hour, on the hour.

While the workflow does run, it does not run at the time it is scheduled i.e. it does not run on the hour. There is a delay which may be of more than 30 minutes. I don't know why this is.

It is not the workflow itself because it executes when I manually run it in approximately 30 seconds.

Can someone please tell me what is causing the delay?

Is it a time-zone issue? Even so, there should be a fixed interval of 1 hour between two consecutive workflow runs which is not the case.

This is the code.

# This is a basic workflow to help you get started with Actions

name: Email every hour

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  schedule:
    - cron: "0 */1 * * *"

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.8]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Set up Python environment
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}

      # Install dependencies
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          
      # Run script to send email
      - name: Run script
        run: python emailer.py
        env:
          EMAIL_USER: ${{ secrets.EMAIL_USER }}
          EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
          TO_EMAIL: ${{ secrets.TO_EMAIL }} 

Github Repo

5
  • 3
    I am running into this issue now, did you ever find a solution / explanation ?
    – gowerc
    Dec 20, 2020 at 12:50
  • @gowerc The issue somehow fixed itself after a few days. I am guessing the issue was on Github's end. Now, the code runs on the hour, every hour, as it should. Runs have a gap of approximately an hour between them. Dec 21, 2020 at 3:30
  • I have the same issue, looking for answers as well
    – Corel
    Jan 1, 2021 at 0:29
  • 3
    I contacted gh support and they said that they are aware of it, but there's nothing on their public roadmap
    – dimisjim
    Jan 5, 2021 at 10:31
  • Note: However the minimum time period to run scheduled jobs has changed to 5 minutes. In other words, a cron job of * * * * * will not run for every minute, but for 5 minutes. Mar 5, 2021 at 23:46

2 Answers 2

23

When you set up a GitHub Actions workflow with a schedule, say for once every 10 minutes, you're essentially requesting GitHub to schedule that workflow for you. There is no guarantee that the workflow will run every 10 minutes.

In a discussion in the GitHub Support Community (No assurance on scheduled jobs?), Github partner @brightran said that many times, there may be a delay when triggering the scheduled workflow:

Generally, the delay time is about 3 to 10 minutes. Sometimes, it may be more, even dozens of minutes, or more than one hour.

He also said that if the delay time is too long, the scheduled workflow may be not triggered at that day. Therefore, it's not recommended to use GitHub Actions scheduled workflows for production tasks that require execution guarantee.

Source

1
  • 5
    I wonder if it's changed at this point. I can understand the delay, but the fact that it might not even run seems completely insane. They may as well just tell you not to use it.
    – twiz
    Aug 11, 2022 at 10:08
-4

Cron jobs on github actions are triggered according to UTC time. The delay, on the other hand, might be just a serverside issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.