为什么计划的Github操作工作流没有在正确的时间触发cron? [英] Why is Github Actions workflow scheduled with cron not triggering at the right time?

查看:53
本文介绍了为什么计划的Github操作工作流没有在正确的时间触发cron?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个每小时、每小时触发的Github操作工作流。

虽然工作流确实运行,但它不会在计划的时间运行,即它不会在整点运行。可能有超过30分钟的延误。我不知道为什么会这样。

它不是工作流本身,因为它在我大约30秒后手动运行时执行。

有人能告诉我延误的原因吗?

这是时区问题吗?即使如此,在两个连续的工作流运行之间应该有1小时的固定间隔,但情况并非如此。

这是代码。

# 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

推荐答案

当您使用计划设置GitHub操作工作流(例如每10分钟一次)时,您实际上是在请求GitHub为您计划该工作流。不能保证工作流每10分钟运行一次。

在GitHub支持社区(No assurance on scheduled jobs?)的讨论中,Github合作伙伴@brightran多次表示,触发计划的工作流可能会延迟:

一般延误时间在3到10分钟左右。有时候,它可能 可能更多,甚至几十分钟,或者超过一个小时。

他还表示,如果延误时间过长,当天可能不会触发预定的工作流程。因此,不建议对需要执行保证的生产任务使用GitHub操作计划工作流。

Source

这篇关于为什么计划的Github操作工作流没有在正确的时间触发cron?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆