如何在特定分支上触发计划操作?

cbl*_*bll 9 github github-actions

我已经采取行动了。我希望它foo按计划在分支上运行(在我的例子中,每天两次)。

这是我到目前为止所得到的:

repo/.github/workflows/daily-foo-tests.yml

name: Run integration tests on foo branch twice a day
on:
  schedule:
    # Execute at 00:01 and 13:01 UTC daily
    - cron:  '00 01,13 * * *'

jobs:
  build:
    name: Run UI Automation
    runs-on: [self-hosted, macOS, X64]
    steps:
      - uses: actions/checkout@v2
      - name: dotnet build
        with: { ref: foo }
        // continues to do stuff, not important
Run Code Online (Sandbox Code Playgroud)

目前,该行动已推送至该foo分支机构。然而,转到github.com/org/repo/actions,它不会触发(我已经等了 24 小时了;此时它应该已经做了一些事情)。

在指定分支上触发计划的 github 操作工作流程的正确方法是什么?

pet*_*ans 12

工作流必须提交到要触发的默认分支。如果您只将其提交到非默认分支,它将不起作用。

计划的工作流在默认或基础分支上的最新提交上运行。

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

例如,这应该提交到默认分支。当它运行时,它会检查分支foo,然后您可以构建、测试等。

on:
  schedule:
    - cron:  '0 1 * * 4'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: foo
      
      # Build steps go here
Run Code Online (Sandbox Code Playgroud)