Skip to content

Latest commit

 

History

History
67 lines (41 loc) · 2.69 KB

README.md

File metadata and controls

67 lines (41 loc) · 2.69 KB

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"}}'

Example CI Output

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"}}'

Example CI Output

Multiple dirs, same step

multi_single_step.yml

Example CI Output

Run from a container

container.yml

Example CI Output

Create a PAT

https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line