Skip to content

Repository Dispatch Event Snippet

This code is used to trigger a repository_dispatch in another repository. The event_type here must match the types set there.

Prerequisites

This action requires that node.js is setup & octokit is installed.

Code

- uses: actions/github-script@v6.3.3
  with:
    script: |
      const { Octokit } = require("@octokit/action");
      const octokit = new Octokit
      ({
        auth: '${{ env.GITHUB_TOKEN }}'
      })
      await octokit.rest.repos.createDispatchEvent
      ({
        owner: '${{ github.repository_owner }}',
        repo: '${{ matrix.parent_repo_name }}',
        event_type: '${{ env.EVENT_TYPE }}',
        client_payload: {
          submodule_name: '${{ github.event.repository.name }}',
          commit_message: `${{ github.event.head_commit.message }}`
        }
      });