Github 操作,在分支上安排操作

Github actions, schedule operation on branch

我正在尝试配置 github 工作流程,我已设法在推送事件时配置它。但是,如果我需要它在一段时间后 运行 打开怎么办?

我从documentation了解到的是可以用一个schedule来实现。

name: Release Management

on: 
  schedule:
   - cron: "*/5 * * * *"

如何指定操作 运行 的分支?

我的最终目标是自动化发布。

如果您查看 documentation here,您将看到与 on: schedule 事件关联的 GITHUB_SHA 是“默认分支上的最后一次提交”。这是当您使用 actions/checkout 操作时默认签出的内容。

如果您的存储库的默认分支是 master(通常是这种情况),此工作流将在触发时检出 master 上的最后一次提交。

name: Release Management
on: 
  schedule:
   - cron: "*/5 * * * *"
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

如果您想签出不同的分支,您可以在签出操作中指定参数。此工作流程将检出 some-branch 分支上的最后一次提交。

name: Release Management
on: 
  schedule:
   - cron: "*/5 * * * *"
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: some-branch

有关其他选项,请参阅 documentation for the actions/checkout 操作。