Skip to content

Commit 6557c72

Browse files
committed
Add support for creating a repo dispatch evnet
1 parent b79d090 commit 6557c72

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

doc/repos.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,11 @@ You can optionally assign some teams by passing an array with their ID's if you'
346346
```php
347347
$repo = $client->api('repo')->transfer('KnpLabs', 'php-github-api', 'github', [1234]);
348348
```
349+
350+
### Create a repository dispatch event
351+
352+
Example when you want to configure custom github action workflows.
353+
354+
```php
355+
$client->api('repo')->dispatch('KnpLabs', 'php-github-api', 'acme-event', ['foo'=>'bar']);
356+
```

lib/Github/Api/Repo.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,26 @@ public function readme($username, $repository, $format = 'raw')
276276
]);
277277
}
278278

279+
/**
280+
* Create a repository dispatch event
281+
*
282+
* @link https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
283+
*
284+
* @param string $username the user who owns the repository
285+
* @param string $repository the name of the repository
286+
* @param string $eventType A custom webhook event name
287+
*
288+
* @return mixed null on success, array on error with 'message'
289+
*/
290+
public function dispatch($username, $repository, $eventType, array $clientPayload)
291+
{
292+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository), [
293+
'event_type' => $eventType,
294+
'client_payload' => $clientPayload,
295+
]);
296+
}
297+
298+
279299
/**
280300
* Manage the collaborators of a repository.
281301
*

0 commit comments

Comments
 (0)