Whats is the difference between repository_dispatch and workflow_dispatch in Github Actions?

Viewed 4489

Please explain the difference between these 2 event triggers with some real world example.

1 Answers

Apparently, repository_dispatch events may only be read on the default branch

See:

For the latter, from William Villeneuve :

# TODO: replace :token, :user, and :repo
curl -H "Authorization: token :token" \
    -H 'Accept: application/vnd.github.everest-preview+json' \
    "https://api.github.com/repos/:user/:repo/dispatches" \
    -d '{"event_type": "awesomeness", "client_payload": {"foo": "bar"}}'
name: example-client-payload-action
on: repository_dispatch
jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: 'echo "field: ${{ github.event.client_payload.foo }}"'
      - run: 'echo "payload: ${{ toJson(github.event.client_payload) }}"'
      - run: echo baz
        if: github.event.action == 'baz'

As seen here:

Just posting here since it doesn't seem to be documented - you can also specify a list of types to trigger on:

on:
  repository_dispatch:
    types:
      - manual-trigger-mytest
      - manual-trigger-all

From "Manually Trigger A GitHub Actions Workflow"

Related