Trigger a GitHub action with repository_dispatch

Have you ever wanted or just wondered if running a GitHub Action workflow is possible by essentially hitting a webhook?

Yes, it is! Create a repository dispatch event and make sure the workflow yaml has the repository_dispatch.

Once you have this set up:

on:
    repository_dispatch:
        types: [on-something-happened]

Do this:

curl \
    -X POST \
    -H "Accept: application/vnd.github+json" \ 
    -H "Authorization: Bearer <YOUR-TOKEN>" \
    https://api.github.com/repos/OWNER/REPO/dispatches \
    -d '{"event_type":"on-something-happened"}'