GitHub Repository Dispatch Event

Trigger a GitHub Actions workflow or GitHub App webhook.

This type of integration uses the repository_dispatch endpoint of GitHub.

By default, all repository_dispatch activity types trigger a workflow to run, so if you want to limit this to a specific event type, you need to define that in your GitHub workflow.

The following example uses the versionPublished event:

on:
  repository_dispatch:
    types: [locize/versionPublished]

The data that is sent through the client_payload parameter will be available in the github.event context in your workflow. For example, for a versionPublished event, you can access the payload in a workflow like this:

on:
  push:
    branches: [main]
  repository_dispatch:
    types: [locize/versionPublished]

jobs:
  test1:
    name: Test1 (conditional run)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: 'echo "field: ${{ github.event.client_payload.payload.version }}"'
      - run: 'echo "payload: ${{ toJson(github.event.client_payload) }}"'
      - run: echo baz
        if: github.event.client_payload.payload.version == 'production'
  test2:
    name: Test2 (conditional step)
    if: github.event.client_payload.payload.version == 'production'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: 'echo "field: ${{ github.event.client_payload.payload.version }}"'
      - run: 'echo "payload: ${{ toJson(github.event.client_payload) }}"'

The object passed via github.event.client_payload is the event specified here.

This way you can for example also do some extra conditional checks, like check if the event is coming from the expected version, etc.

The used GitHub token requires write access to the repository by providing either:

Last updated