Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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/repo/actions/workflow_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ https://docs.github.com/en/rest/reference/actions#delete-workflow-run-logs
```php
$client->api('repo')->workflowRuns()->deleteLogs('KnpLabs', 'php-github-api', $runId);
```

### Approve workflow run

https://docs.github.com/en/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request

```php
$client->api('repo')->workflowRuns()->approve('KnpLabs', 'php-github-api', $runId);
```
16 changes: 16 additions & 0 deletions lib/Github/Api/Repository/Actions/WorkflowRuns.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,20 @@ public function deleteLogs(string $username, string $repository, int $runId)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs');
}

/**
* @link https://docs.github.com/en/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array|string
*
* @experimental This endpoint is currently in beta.
*/
public function approve(string $username, string $repository, int $runId)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/approve');
}
}
18 changes: 18 additions & 0 deletions test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@ public function shouldDeleteWorkflowRunLogs()
$this->assertEquals($expectedValue, $api->deleteLogs('KnpLabs', 'php-github-api', 374473304));
}

/**
* @test
*/
public function shouldApproveWorkflowRunLogs()
{
$expectedValue = 'response';

/** @var WorkflowRuns|MockObject $api */
$api = $this->getApiMock();

$api->expects($this->once())
->method('post')
->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/approve')
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->approve('KnpLabs', 'php-github-api', 374473304));
}

protected function getApiClass()
{
return WorkflowRuns::class;
Expand Down