GARS

Repository Dispatch

If you wish to trigger a workflow externally, the repository_dispatch event is the one to look into.

Here's an example workflow which uses this trigger and will echo 'Hello!' when you send a request to it with the event_type of test

workflow.yml
name: Dispatch action
on: repository_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Say hello on 'test' event
if: github.event.action == 'test'
run: |
echo 'Hello!'

Then, you can send a POST request to the API as follows:

exec.sh
curl -H "Authorization: token $GITHUB_TOKEN" \
-H 'Accept: application/vnd.github.everest-preview+json' \
"https://api.github.com/repos/username/MyRepo/dispatches" \
-d '{"event_type": "test"}'

you need to use a Personal Access Token for authorization purposes. as well, you need to put a event_type in the body of the POST. this event type matches up to github.event.action in the GitHub context available to your workflow.

As well, if you wish to add a payload, the POST can also take client_payload which is an object which then will be available at github.event.client_payload on the Actions side.

Edit this page on GitHub