Workflow_dispatch event not working

Hello,

I trigger a github action with the following workflow:

name: CI

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Run a one-line script
      run: echo Hello, world!

that is completed correctly.

I expect that a workflow_dispatch event will be emitted but it seems it does not. Do I understand something wrong on how the webhook event is supposed to work?
(I have tried triggering the workflow from the Github UI as well as the cli nothing is working.)

@nicolasmanic,

I have tried triggering the workflow from the Github UI as well as the cli nothing is working.

Is the workflow file of “CI” existing on the master or default branch? Can you see the “Run workflow” button for this workflow on the GitHub web UI?

Here are few points may be helpful to you:

  1. To manually trigger a workflow with workflow_dispatch event on the GitHub web UI (click “Run workflow” button), the workflow file should also exist on the master or default branch.

  2. If the workflow file exists on other branches but not on the master or default branch, you can’t see the “Run workflow” button on the web UI, and only can use the “Create a workflow dispatch event” API to trigger the workflow.

  3. If the workflow file exists on other branches but not on the master or default branch, the workflow should have been triggered at least once before you can trigger it via the “Create a workflow dispatch event” API. This means that you may need to trigger this workflow at least once when the workflow file is existing on the master or default branch. Then you can delete the workflow file from the master or default branch.

Hi @brightran thanks for the reply.
Yes the “CI” exists on master branch. And I’m able to see the “ Run workflow ” button for this workflow on the GitHub web UI.

Take a look at this example https://github.com/nicolasmanic/test
The produced webhook events after a successful run of the workflow are the following:

  • X-GitHub-Event: check_run
  • X-GitHub-Event: check_suite

I expect to be at lest one event with X-GitHub-Event: workflow_dispatch

@nicolasmanic,

Looks like you want that the workflow_dispatch event can be add to the repository’s Settings > Webhooks so that you can select this event to trigger the webhook you add.

If so, I recommend that you can directly report a feature request here to ask adding the workflow_dispatch as a webhook event in the repository settings.
That will allow you to directly interact with the appropriate engineering team, and make it more convenient for the engineering team to collect and categorize your suggestions.

@brightran I thought that this was already available,

In the documentation it stated the following:

This event occurs when someone triggers a workflow run on GitHub or sends a POST request to the “Create a workflow dispatch event” endpoint

I’m sorry if I misunderstood something but it seems that if I create a workflow run on GitHub a workflow_dispatch event should be emitted by the webhook. Am I mistaken?

@nicolasmanic,

This event occurs when someone triggers a workflow run on GitHub or sends a POST request to the “Create a workflow dispatch event” endpoint.

This is saying that when a user clicks the “Run workflow” button on GitHub or executes the Create a workflow dispatch event API, a webhook will be sent to the related GitHub repository to trigger the workflows run on the workflow_dispatch event.

On the repository’s Settings > Webhooks page, it allows users to sent the webhooks for some events to the external services.
Currently, not all the webhooks for the events on GitHub can be sent to the external services. I check the list of the events that we can select, it seems that the Manual events (workflow_dispatch and repository_dispatch) are not allowed to send webhooks to the external services.

If your projects really need to send the webhooks for the Manual events to the external services, as I mentioned in previous reply, you can directly report a feature request here to ask adding the Manual events in the list.