通过存储库调度事件触发时如何在工作流中指定event_type

时间:2019-09-17 13:29:35

标签: github-api github-actions

我正在尝试设置工作流,以通过herehere指定的方式通过Github Actions的“存储库分发事件”触发。作为对API请求的输入,它指定我需要包括一个事件类型,作为自定义的webhook事件名称。

但是,我还希望能够在我的工作流程中使用此事件类型,以便我可以有多个由repository_dispatch选项触发的工作流程,每个工作流程都由自己的事件类型触发。

如关于how to use webhook event triggers的部分所述,我在声明何时触发工作流时尝试使用类型字段(请参见代码)。但是,这只会导致什么都不会触发。如果我忽略“类型”字段,则会触发工作流程。

这是我的工作流程

name: External trigger

on:
  repository_dispatch
    types: external_test

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - name: Say hi
        run: echo "Hi!"

这是API请求有效负载:

{
    "event_type": "external_test"
}

1 个答案:

答案 0 :(得分:4)

:之后缺少repository_dispatch,因此Yaml无效。

name: External trigger

on:
  repository_dispatch:
    types: external_test