Execute a github workflow manually
Below are several examples for how to kick off workflow jobs manually via curl (or any external event)
Create workflow at .github/workflows/file.yml
Notice the event_type
matches the workflow field: on.repository_dispatch.types
. the workflow file name does not need to match.
Execute a basic job
$ curl -XPOST -u "drewmullen" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/drewmullen/actions-playground/dispatches \
--data '{"event_type": "external-echo"}'
Enter host password for user 'drewmullen': <YOUR PAT>
Specify a branch
repository_dispatch
always uses master branch. To use another branch, view this workflow and set client_payload.ref
:
curl -XPOST -u "drewmullen" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/drewmullen/actions-playground/dispatches \
--data '{"event_type": "my-dispatch", "client_payload": {"ref": "test-pr4"}}'
Condition steps to run based on input
If you'd like the same event to kick of specific jobs, use the if
condition.
curl -XPOST -u "drewmullen" \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Content-Type: application/json" \
https://api.github.com/repos/drewmullen/actions-playground/dispatches \
--data '{"event_type": "multi-dispatch", "client_payload": {"ref": "test-pr6", "project": "dir1"}}'