Skip to content

Commit

Permalink
feature #939 Actions (#872) (lexor)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x branch.

Discussion
----------

- [x] Artifacts
- [x] Secrets
- [x] Self-hosted runners
- [x] Workflows
- [x] Workflow jobs
- [x] Workflow runs

Documentation: https://developer.github.com/v3/actions/

Commits
-------

703955e repo: added actions
  • Loading branch information
acrobat authored Dec 3, 2020
2 parents 50a1c51 + 703955e commit 0889fc2
Show file tree
Hide file tree
Showing 24 changed files with 1,967 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,6 @@ This library is maintained by the following people (alphabetically sorted) :
- Thanks to [Nicolas Pastorino](http://github.com/jeanvoye) for his contribution on the Pull Request API.
- Thanks to [Edoardo Rivello](http://github.com/erivello) for his contribution on the Gists API.
- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API.
- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API.

Thanks to GitHub for the high quality API and documentation.
85 changes: 85 additions & 0 deletions doc/organization/actions/secrets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## Organization / Secrets API
[Back to the "Organization API"](../organization.md) | [Back to the navigation](../README.md)

### List organization secrets

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-organization-secrets

```php
$secrets = $client->organization()->secrets()->all('KnpLabs');
```

### Get an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-secret

```php
$secret = $client->organization()->secrets()->show('KnpLabs', $secretName);
```

### Create an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret

```php
$client->organization()->secrets()->create('KnpLabs', $secretName, [
'encrypted_value' => $encryptedValue,
'visibility' => $visibility,
'selected_repository_ids' => $selectedRepositoryIds,
]);
```

### Update an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret

```php
$client->organization()->secrets()->update('KnpLabs', $secretName, [
'key_id' => 'keyId',
'encrypted_value' => 'encryptedValue',
'visibility' => 'private',
]);
```

### Delete an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-organization-secret

```php
$client->organization()->secrets()->remove('KnpLabs', $secretName);
```

### List selected repositories for organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-selected-repositories-for-an-organization-secret

```php
$client->organization()->secrets()->selectedRepositories('KnpLabs', $secretName);
```

### Set selected repositories for an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#set-selected-repositories-for-an-organization-secret

```php
$client->organization()->secrets()->setSelectedRepositories('KnpLabs', 'secretName', [
'selected_repository_ids' => [1, 2, 3],
]);
```

### Remove selected repository from an organization secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#remove-selected-repository-from-an-organization-secret

```php
$client->organization()->secrets()->addSecret('KnpLabs', $repositoryId, $secretName);
```

### Get an organization public key

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-public-key

```php
$client->organization()->secrets()->publicKey('KnpLabs');
```

44 changes: 44 additions & 0 deletions doc/repo/actions/artifacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Repo / Artifacts API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

### List artifacts for a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-artifacts-for-a-repository

```php
$artifacts = $client->api('repo')->artifacts()->all('KnpLabs');
```

### List workflow run artifacts

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-run-artifacts

```php
$runArtifacts = $client->api('repo')->artifacts()->runArtifacts('KnpLabs', 'php-github-api', $runId);
```

### Get an artifact

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-artifact

```php
$artifact = $client->api('repo')->artifacts()->show('KnpLabs', 'php-github-api', $artifactId);
```

### Delete an artifact

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-artifact

```php
$client->api('repo')->artifacts()->delete('KnpLabs', 'php-github-api', $artifactId);
```


### Download an artifact

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact

```php
$artifactFile = $client->api('repo')->artifacts()->download('KnpLabs', 'php-github-api', $artifactId, $format = 'zip');
file_put_contents($artifactId.'.'.$format, $artifactFile);
```
54 changes: 54 additions & 0 deletions doc/repo/actions/secrets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Repo / Secrets API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

### List repository secrets

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-secrets

```php
$secrets = $client->api('repo')->secrets()->all('KnpLabs', 'php-github-api');
```

### Get a repository secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-secret

```php
$secret = $client->api('repo')->secrets()->show('KnpLabs', 'php-github-api', $secretName);
```

### Create a repository secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret

```php
$client->api('repo')->secrets()->create('KnpLabs', 'php-github-api', $secretName, [
'encrypted_value' => $encryptedValue,
]); $client->api('repo')->secrets()->all();
```

### Update a repository secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret

```php
$client->api('repo')->secrets()->update('KnpLabs', 'php-github-api', $secretName, [
'key_id' => $keyId, 'encrypted_value' => $encryptedValue,
]);
```

### Delete a repository secret

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-repository-secret

```php
$client->api('repo')->secrets()->remove('KnpLabs', 'php-github-api', $secretName);
```

### Get a repository public key

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-public-key

```php
$publicKey = $client->api('repo')->secrets()->publicKey('KnpLabs', 'php-github-api');
```
35 changes: 35 additions & 0 deletions doc/repo/actions/self_hosted_runners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## Repo / Self Hosted Runners API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

# List self-hosted runners for a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-self-hosted-runners-for-a-repository

```php
$runners = $client->api('repo')->selfHostedRunners()->all('KnpLabs', 'php-github-api');
```

# Get a self-hosted runner for a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-self-hosted-runner-for-a-repository

```php
$runner = $client->api('repo')->selfHostedRunners()->show('KnpLabs', 'php-github-api', $runnerId);
```

# Delete a self-hosted runner from a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository

```php
$client->api('repo')->selfHostedRunners()->remove('KnpLabs', 'php-github-api', $runnerId);
```

# List runner applications for a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-runner-applications-for-a-repository

```php
$applications = $client->api('repo')->selfHostedRunners()->applications('KnpLabs', 'php-github-api');
```

27 changes: 27 additions & 0 deletions doc/repo/actions/workflow_jobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Repo / Workflow Jobs API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

### List jobs for a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run

```php
$client->api('repo')->workflowJobs()->all('KnpLabs', 'php-github-api', $runId);
```

### Get a job for a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-job-for-a-workflow-run

```php
$job = $client->api('repo')->workflowJobs()->all('KnpLabs', 'php-github-api', $jobId);
```

### Download job logs for a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-job-logs-for-a-workflow-run

```php
$jobLogs = $client->api('repo')->workflowJobs()->downloadLogs('KnpLabs', 'php-github-api', $jobId);
file_put_contents('jobLogs.zip', $jobLogs);
```
76 changes: 76 additions & 0 deletions doc/repo/actions/workflow_runs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
## Repo / Workflow Runs API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

### List workflow runs for a repository

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs-for-a-repository

```php
$workflowRuns = $client->api('repo')->workflowRuns()->all('KnpLabs', 'php-github-api');
```

### List workflow runs

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs

```php
$runs = $client->api('repo')->workflowRuns()->listRuns('KnpLabs', 'php-github-api', $workflowId);
```

### Get a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow-run

```php
$workflowRun = $client->api('repo')->workflowRuns()->show('KnpLabs', 'php-github-api', $runId);
```

### Delete a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-workflow-run

```php
$client->api('repo')->workflowRuns()->remove('KnpLabs', 'php-github-api', $runId);
```

### Re-run a workflow

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#re-run-a-workflow

```php
$client->api('repo')->workflowRuns()->rerun('KnpLabs', 'php-github-api', $runId);
```

### Cancel a workflow run

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#cancel-a-workflow-run

```php
$client->api('repo')->workflowRuns()->cancel('KnpLabs', 'php-github-api', $runId);
```

### Get workflow run usage

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-run-usage

```php
$workflowUsage = $client->api('repo')->workflowRuns()->usage('KnpLabs', 'php-github-api', $runId);
```

### Download workflow run logs

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-workflow-run-logs

```php
$logs = $client->api('repo')->workflowRuns()->downloadLogs('KnpLabs', 'php-github-api', $runId);

file_put_contents('logs.zip', $logs);
```

### Delete workflow run logs

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-workflow-run-logs

```php
$client->api('repo')->workflowRuns()->deleteLogs('KnpLabs', 'php-github-api', $runId);
```
26 changes: 26 additions & 0 deletions doc/repo/actions/workflows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Repo / Workflows API
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)

### List repository workflows

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-workflows

```php
$workflows = $client->api('repo')->workflows()->all('KnpLabs', 'php-github-api');
```

### Get a workflow

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow

```php
$workflow = $client->api('repo')->workflows()->show('KnpLabs', 'php-github-api', $workflowId);
```

### Get workflow usage

https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-usage

```php
$usage = $client->api('repo')->workflows()->usage('KnpLabs', 'php-github-api', $workflowId);
```
9 changes: 9 additions & 0 deletions lib/Github/Api/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Github\Api;

use Github\Api\Organization\Actions\Secrets;
use Github\Api\Organization\Hooks;
use Github\Api\Organization\Members;
use Github\Api\Organization\OutsideCollaborators;
Expand Down Expand Up @@ -101,6 +102,14 @@ public function teams()
return new Teams($this->client);
}

/**
* @return Secrets
*/
public function secrets(): Secrets
{
return new Secrets($this->client);
}

/**
* @return OutsideCollaborators
*/
Expand Down
Loading

0 comments on commit 0889fc2

Please sign in to comment.