GitHub Repository Dispatch Event

Trigger a GitHub Actions workflow or GitHub App webhook.

This type of integration uses the repository_dispatcharrow-up-right endpoint of GitHub.

By default, all repository_dispatcharrow-up-right 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 workflowarrow-up-right.

The following example uses the versionPublished event:

on:
  repository_dispatch:
    types: [locize/versionPublished]

The data that is sent through the client_payloadarrow-up-right 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.

circle-exclamation

Last updated