'How to run a workflow using github cli?

% gh workflow run test.yml

gives me:

could not create workflow dispatch event: HTTP 422: Workflow does not have 'workflow_dispatch' trigger (https://api.github.com/repos/bcpitutor/v2_lms/actions/workflows/20724896/dispatches)

Why do I need a workflow_dispatch trigger?



Solution 1:[1]

The gh workflow run man page does confirm:

The given workflow file must support a workflow_dispatch 'on' trigger in order to be run in this way.

It comes from cli/cli issue 1725, and issue 2889, implemented by PR 3303.

This PR implements gh workflow run, a command for creating workflow_dispatch events for workflows that support them

Again, a confirmation your workflow needs to support that workflow_dispatch trigger.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC