Skip to content

Commit 0889fc2

Browse files
authored
feature KnpLabs#939 Actions (KnpLabs#872) (lexor)
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
2 parents 50a1c51 + 703955e commit 0889fc2

24 files changed

+1967
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@ This library is maintained by the following people (alphabetically sorted) :
109109
- Thanks to [Nicolas Pastorino](http://github.com/jeanvoye) for his contribution on the Pull Request API.
110110
- Thanks to [Edoardo Rivello](http://github.com/erivello) for his contribution on the Gists API.
111111
- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API.
112+
- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API.
112113

113114
Thanks to GitHub for the high quality API and documentation.

doc/organization/actions/secrets.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Organization / Secrets API
2+
[Back to the "Organization API"](../organization.md) | [Back to the navigation](../README.md)
3+
4+
### List organization secrets
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-organization-secrets
7+
8+
```php
9+
$secrets = $client->organization()->secrets()->all('KnpLabs');
10+
```
11+
12+
### Get an organization secret
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-secret
15+
16+
```php
17+
$secret = $client->organization()->secrets()->show('KnpLabs', $secretName);
18+
```
19+
20+
### Create an organization secret
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret
23+
24+
```php
25+
$client->organization()->secrets()->create('KnpLabs', $secretName, [
26+
'encrypted_value' => $encryptedValue,
27+
'visibility' => $visibility,
28+
'selected_repository_ids' => $selectedRepositoryIds,
29+
]);
30+
```
31+
32+
### Update an organization secret
33+
34+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-an-organization-secret
35+
36+
```php
37+
$client->organization()->secrets()->update('KnpLabs', $secretName, [
38+
'key_id' => 'keyId',
39+
'encrypted_value' => 'encryptedValue',
40+
'visibility' => 'private',
41+
]);
42+
```
43+
44+
### Delete an organization secret
45+
46+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-organization-secret
47+
48+
```php
49+
$client->organization()->secrets()->remove('KnpLabs', $secretName);
50+
```
51+
52+
### List selected repositories for organization secret
53+
54+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-selected-repositories-for-an-organization-secret
55+
56+
```php
57+
$client->organization()->secrets()->selectedRepositories('KnpLabs', $secretName);
58+
```
59+
60+
### Set selected repositories for an organization secret
61+
62+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#set-selected-repositories-for-an-organization-secret
63+
64+
```php
65+
$client->organization()->secrets()->setSelectedRepositories('KnpLabs', 'secretName', [
66+
'selected_repository_ids' => [1, 2, 3],
67+
]);
68+
```
69+
70+
### Remove selected repository from an organization secret
71+
72+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#remove-selected-repository-from-an-organization-secret
73+
74+
```php
75+
$client->organization()->secrets()->addSecret('KnpLabs', $repositoryId, $secretName);
76+
```
77+
78+
### Get an organization public key
79+
80+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-organization-public-key
81+
82+
```php
83+
$client->organization()->secrets()->publicKey('KnpLabs');
84+
```
85+

doc/repo/actions/artifacts.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## Repo / Artifacts API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List artifacts for a repository
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-artifacts-for-a-repository
7+
8+
```php
9+
$artifacts = $client->api('repo')->artifacts()->all('KnpLabs');
10+
```
11+
12+
### List workflow run artifacts
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-run-artifacts
15+
16+
```php
17+
$runArtifacts = $client->api('repo')->artifacts()->runArtifacts('KnpLabs', 'php-github-api', $runId);
18+
```
19+
20+
### Get an artifact
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-an-artifact
23+
24+
```php
25+
$artifact = $client->api('repo')->artifacts()->show('KnpLabs', 'php-github-api', $artifactId);
26+
```
27+
28+
### Delete an artifact
29+
30+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-an-artifact
31+
32+
```php
33+
$client->api('repo')->artifacts()->delete('KnpLabs', 'php-github-api', $artifactId);
34+
```
35+
36+
37+
### Download an artifact
38+
39+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-an-artifact
40+
41+
```php
42+
$artifactFile = $client->api('repo')->artifacts()->download('KnpLabs', 'php-github-api', $artifactId, $format = 'zip');
43+
file_put_contents($artifactId.'.'.$format, $artifactFile);
44+
```

doc/repo/actions/secrets.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Repo / Secrets API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List repository secrets
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-secrets
7+
8+
```php
9+
$secrets = $client->api('repo')->secrets()->all('KnpLabs', 'php-github-api');
10+
```
11+
12+
### Get a repository secret
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-secret
15+
16+
```php
17+
$secret = $client->api('repo')->secrets()->show('KnpLabs', 'php-github-api', $secretName);
18+
```
19+
20+
### Create a repository secret
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret
23+
24+
```php
25+
$client->api('repo')->secrets()->create('KnpLabs', 'php-github-api', $secretName, [
26+
'encrypted_value' => $encryptedValue,
27+
]); $client->api('repo')->secrets()->all();
28+
```
29+
30+
### Update a repository secret
31+
32+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-or-update-a-repository-secret
33+
34+
```php
35+
$client->api('repo')->secrets()->update('KnpLabs', 'php-github-api', $secretName, [
36+
'key_id' => $keyId, 'encrypted_value' => $encryptedValue,
37+
]);
38+
```
39+
40+
### Delete a repository secret
41+
42+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-repository-secret
43+
44+
```php
45+
$client->api('repo')->secrets()->remove('KnpLabs', 'php-github-api', $secretName);
46+
```
47+
48+
### Get a repository public key
49+
50+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-repository-public-key
51+
52+
```php
53+
$publicKey = $client->api('repo')->secrets()->publicKey('KnpLabs', 'php-github-api');
54+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Repo / Self Hosted Runners API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
# List self-hosted runners for a repository
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-self-hosted-runners-for-a-repository
7+
8+
```php
9+
$runners = $client->api('repo')->selfHostedRunners()->all('KnpLabs', 'php-github-api');
10+
```
11+
12+
# Get a self-hosted runner for a repository
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-self-hosted-runner-for-a-repository
15+
16+
```php
17+
$runner = $client->api('repo')->selfHostedRunners()->show('KnpLabs', 'php-github-api', $runnerId);
18+
```
19+
20+
# Delete a self-hosted runner from a repository
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository
23+
24+
```php
25+
$client->api('repo')->selfHostedRunners()->remove('KnpLabs', 'php-github-api', $runnerId);
26+
```
27+
28+
# List runner applications for a repository
29+
30+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-runner-applications-for-a-repository
31+
32+
```php
33+
$applications = $client->api('repo')->selfHostedRunners()->applications('KnpLabs', 'php-github-api');
34+
```
35+

doc/repo/actions/workflow_jobs.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Repo / Workflow Jobs API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List jobs for a workflow run
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-jobs-for-a-workflow-run
7+
8+
```php
9+
$client->api('repo')->workflowJobs()->all('KnpLabs', 'php-github-api', $runId);
10+
```
11+
12+
### Get a job for a workflow run
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-job-for-a-workflow-run
15+
16+
```php
17+
$job = $client->api('repo')->workflowJobs()->all('KnpLabs', 'php-github-api', $jobId);
18+
```
19+
20+
### Download job logs for a workflow run
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-job-logs-for-a-workflow-run
23+
24+
```php
25+
$jobLogs = $client->api('repo')->workflowJobs()->downloadLogs('KnpLabs', 'php-github-api', $jobId);
26+
file_put_contents('jobLogs.zip', $jobLogs);
27+
```

doc/repo/actions/workflow_runs.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Repo / Workflow Runs API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List workflow runs for a repository
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs-for-a-repository
7+
8+
```php
9+
$workflowRuns = $client->api('repo')->workflowRuns()->all('KnpLabs', 'php-github-api');
10+
```
11+
12+
### List workflow runs
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs
15+
16+
```php
17+
$runs = $client->api('repo')->workflowRuns()->listRuns('KnpLabs', 'php-github-api', $workflowId);
18+
```
19+
20+
### Get a workflow run
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow-run
23+
24+
```php
25+
$workflowRun = $client->api('repo')->workflowRuns()->show('KnpLabs', 'php-github-api', $runId);
26+
```
27+
28+
### Delete a workflow run
29+
30+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-a-workflow-run
31+
32+
```php
33+
$client->api('repo')->workflowRuns()->remove('KnpLabs', 'php-github-api', $runId);
34+
```
35+
36+
### Re-run a workflow
37+
38+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#re-run-a-workflow
39+
40+
```php
41+
$client->api('repo')->workflowRuns()->rerun('KnpLabs', 'php-github-api', $runId);
42+
```
43+
44+
### Cancel a workflow run
45+
46+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#cancel-a-workflow-run
47+
48+
```php
49+
$client->api('repo')->workflowRuns()->cancel('KnpLabs', 'php-github-api', $runId);
50+
```
51+
52+
### Get workflow run usage
53+
54+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-run-usage
55+
56+
```php
57+
$workflowUsage = $client->api('repo')->workflowRuns()->usage('KnpLabs', 'php-github-api', $runId);
58+
```
59+
60+
### Download workflow run logs
61+
62+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#download-workflow-run-logs
63+
64+
```php
65+
$logs = $client->api('repo')->workflowRuns()->downloadLogs('KnpLabs', 'php-github-api', $runId);
66+
67+
file_put_contents('logs.zip', $logs);
68+
```
69+
70+
### Delete workflow run logs
71+
72+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#delete-workflow-run-logs
73+
74+
```php
75+
$client->api('repo')->workflowRuns()->deleteLogs('KnpLabs', 'php-github-api', $runId);
76+
```

doc/repo/actions/workflows.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Repo / Workflows API
2+
[Back to the "Repos API"](../repos.md) | [Back to the navigation](../README.md)
3+
4+
### List repository workflows
5+
6+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-repository-workflows
7+
8+
```php
9+
$workflows = $client->api('repo')->workflows()->all('KnpLabs', 'php-github-api');
10+
```
11+
12+
### Get a workflow
13+
14+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-a-workflow
15+
16+
```php
17+
$workflow = $client->api('repo')->workflows()->show('KnpLabs', 'php-github-api', $workflowId);
18+
```
19+
20+
### Get workflow usage
21+
22+
https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#get-workflow-usage
23+
24+
```php
25+
$usage = $client->api('repo')->workflows()->usage('KnpLabs', 'php-github-api', $workflowId);
26+
```

lib/Github/Api/Organization.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Github\Api;
44

5+
use Github\Api\Organization\Actions\Secrets;
56
use Github\Api\Organization\Hooks;
67
use Github\Api\Organization\Members;
78
use Github\Api\Organization\OutsideCollaborators;
@@ -101,6 +102,14 @@ public function teams()
101102
return new Teams($this->client);
102103
}
103104

105+
/**
106+
* @return Secrets
107+
*/
108+
public function secrets(): Secrets
109+
{
110+
return new Secrets($this->client);
111+
}
112+
104113
/**
105114
* @return OutsideCollaborators
106115
*/

0 commit comments

Comments
 (0)