Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify event_type in workflow, when triggering via a repository dispatch event

I am trying to setup a workflow to be triggered via Github Actions' "Repository Dispatch event", as specified here and here. As input to the API request, it specifies that i need to include an event-type, as a custom webhook event name.

I however also want to be able to use this event-type in my workflow, so that i can have multiple workflows triggered by the repository_dispatch option, each triggered by their own event type.

As specified in the section about how to use webhook event triggers, i have tried using the types field, when declaring when my workflow should trigger (see code). This however only results in nothing being triggered. If i omit the types field, the workflow triggers.

Here is my workflow

name: External trigger

on:
  repository_dispatch
    types: external_test

jobs:
  build:

    runs-on: ubuntu-latest

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

and here is the API request payload:

{
    "event_type": "external_test"
}
like image 490
Elias Jørgensen Avatar asked Sep 17 '19 13:09

Elias Jørgensen


1 Answers

Missing a : after repository_dispatch so the yaml is not valid.

name: External trigger

on:
  repository_dispatch:
    types: external_test
like image 126
peterevans Avatar answered Sep 29 '22 21:09

peterevans