Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/repos.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,11 @@ You can optionally assign some teams by passing an array with their ID's if you'
```php
$repo = $client->api('repo')->transfer('KnpLabs', 'php-github-api', 'github', [1234]);
```

### Create a repository dispatch event

Example when you want to configure custom github action workflows.

```php
$client->api('repo')->dispatch('KnpLabs', 'php-github-api', 'acme-event', ['foo'=>'bar']);
```
19 changes: 19 additions & 0 deletions lib/Github/Api/Repo.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,25 @@ public function readme($username, $repository, $format = 'raw')
]);
}

/**
* Create a repository dispatch event.
*
* @link https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $eventType A custom webhook event name
*
* @return mixed null on success, array on error with 'message'
*/
public function dispatch($username, $repository, $eventType, array $clientPayload)
{
return $this->post(\sprintf('/repos/%s/%s/dispatches', rawurlencode($username), rawurlencode($repository)), [
'event_type' => $eventType,
'client_payload' => $clientPayload,
]);
}

/**
* Manage the collaborators of a repository.
*
Expand Down