Skip to content

Commit 16e1d6d

Browse files
committed
repo: added actions
feat(actions): added self-hosted runners Signed-off-by: Emre DEĞER <ben@emre.dev> repo: added actions feat(actions): added self-hosted runners Signed-off-by: Emre DEĞER <ben@emre.dev> repo: added actions refactored fix(actions: reformated self-hosted runners repo: added actions refactored fix(actions: reformated self-hosted runners feat(actions): added repo's secrets Signed-off-by: Emre DEĞER <ben@emre.dev> feat(actions): added organization's secrets Signed-off-by: Emre DEĞER <ben@emre.dev>
1 parent 562ca30 commit 16e1d6d

File tree

17 files changed

+1592
-0
lines changed

17 files changed

+1592
-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.

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
*/
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?php
2+
3+
namespace Github\Api\Organization\Actions;
4+
5+
use Github\Api\AbstractApi;
6+
7+
/**
8+
* @link https://developer.github.com/v3/actions/secrets/
9+
*/
10+
class Secrets extends AbstractApi
11+
{
12+
/**
13+
* @link https://developer.github.com/v3/actions/secrets/#list-organization-secrets
14+
*
15+
* @param string $organization
16+
*
17+
* @return array|string
18+
*/
19+
public function all(string $organization)
20+
{
21+
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets');
22+
}
23+
24+
/**
25+
* @link https://developer.github.com/v3/actions/secrets/#get-an-organization-secret
26+
*
27+
* @param string $organization
28+
* @param string $secretName
29+
*
30+
* @return array|string
31+
*/
32+
public function show(string $organization, string $secretName)
33+
{
34+
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName));
35+
}
36+
37+
/**
38+
* @link https://developer.github.com/v3/actions/secrets/#create-or-update-an-organization-secret
39+
*
40+
* @param string $organization
41+
* @param string $secretName
42+
* @param string $encryptedValue
43+
* @param string $visibility
44+
* @param array $selectedRepositoryIds
45+
*
46+
* @return array|string
47+
*/
48+
public function create(string $organization, string $secretName, string $encryptedValue, string $visibility = 'all', array $selectedRepositoryIds = [])
49+
{
50+
return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName), [
51+
'encrypted_value' => $encryptedValue,
52+
'visibility' => $visibility,
53+
'selected_repository_ids' => $selectedRepositoryIds,
54+
]);
55+
}
56+
57+
/**
58+
* @link https://developer.github.com/v3/actions/secrets/#create-or-update-an-organization-secret
59+
*
60+
* @param string $organization
61+
* @param string $secretName
62+
* @param string $keyId
63+
* @param string $encryptedValue
64+
* @param string $visibility
65+
* @param array $selectedRepositoryIds
66+
*
67+
* @return array|string
68+
*/
69+
public function update(string $organization, string $secretName, string $keyId, string $encryptedValue, string $visibility = 'all', array $selectedRepositoryIds = [])
70+
{
71+
return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName), [
72+
'key_id' => $keyId,
73+
'encrypted_value' => $encryptedValue,
74+
'visibility' => $visibility,
75+
'selected_repository_ids' => $selectedRepositoryIds,
76+
]);
77+
}
78+
79+
/**
80+
* @link https://developer.github.com/v3/actions/secrets/#delete-an-organization-secret
81+
*
82+
* @param string $organization
83+
* @param string $secretName
84+
*
85+
* @return array|string
86+
*/
87+
public function remove(string $organization, string $secretName)
88+
{
89+
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName));
90+
}
91+
92+
/**
93+
* @link https://developer.github.com/v3/actions/secrets/#list-selected-repositories-for-an-organization-secret
94+
*
95+
* @param string $organization
96+
* @param string $secretName
97+
*
98+
* @return array|string
99+
*/
100+
public function selectedRepositories(string $organization, string $secretName)
101+
{
102+
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories');
103+
}
104+
105+
/**
106+
* @link https://developer.github.com/v3/actions/secrets/#set-selected-repositories-for-an-organization-secret
107+
*
108+
* @param string $organization
109+
* @param string $secretName
110+
* @param array $selectedRepositoryIds
111+
*
112+
* @return array|string
113+
*/
114+
public function setSelectedRepositories(string $organization, string $secretName, array $selectedRepositoryIds = [])
115+
{
116+
return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories', [
117+
'selected_repository_ids' => $selectedRepositoryIds,
118+
]);
119+
}
120+
121+
/**
122+
* @link https://developer.github.com/v3/actions/secrets/#add-selected-repository-to-an-organization-secret
123+
*
124+
* @param string $organization
125+
* @param string $repositoryId
126+
* @param string $secretName
127+
*
128+
* @return array|string
129+
*/
130+
public function addSecret(string $organization, string $repositoryId, string $secretName)
131+
{
132+
return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories/'.$repositoryId);
133+
}
134+
135+
/**
136+
* @link https://developer.github.com/v3/actions/secrets/#remove-selected-repository-from-an-organization-secret
137+
*
138+
* @param string $organization
139+
* @param string $repositoryId
140+
* @param string $secretName
141+
*
142+
* @return array|string
143+
*/
144+
public function removeSecret(string $organization, string $repositoryId, string $secretName)
145+
{
146+
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories/'.$repositoryId);
147+
}
148+
149+
/**
150+
* @link https://developer.github.com/v3/actions/secrets/#get-an-organization-public-key
151+
*
152+
* @param string $organization
153+
*
154+
* @return array|string
155+
*/
156+
public function publicKey(string $organization)
157+
{
158+
return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/secret-key');
159+
}
160+
}

lib/Github/Api/Repo.php

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

33
namespace Github\Api;
44

5+
use Github\Api\Repository\Actions\Artifacts;
6+
use Github\Api\Repository\Actions\Secrets;
7+
use Github\Api\Repository\Actions\WorkflowJobs;
8+
use Github\Api\Repository\Actions\WorkflowRuns;
9+
use Github\Api\Repository\Actions\Workflows;
510
use Github\Api\Repository\Checks;
611
use Github\Api\Repository\Checks\CheckRuns;
712
use Github\Api\Repository\Checks\CheckSuites;
@@ -364,6 +369,46 @@ public function checkSuites(): CheckSuites
364369
return new CheckSuites($this->client);
365370
}
366371

372+
/**
373+
* @link https://developer.github.com/v3/actions/artifacts/#artifacts
374+
*/
375+
public function artifacts(): Artifacts
376+
{
377+
return new Artifacts($this->client);
378+
}
379+
380+
/**
381+
* @link https://developer.github.com/v3/actions/workflows/#workflows
382+
*/
383+
public function workflows(): Workflows
384+
{
385+
return new Workflows($this->client);
386+
}
387+
388+
/**
389+
* @link https://developer.github.com/v3/actions/workflow-runs/#workflow-runs
390+
*/
391+
public function workflowRuns(): WorkflowRuns
392+
{
393+
return new WorkflowRuns($this->client);
394+
}
395+
396+
/**
397+
* @link https://developer.github.com/v3/actions/workflow-jobs/#workflow-jobs
398+
*/
399+
public function workflowJobs(): WorkflowJobs
400+
{
401+
return new WorkflowJobs($this->client);
402+
}
403+
404+
/**
405+
* @link https://developer.github.com/v3/actions/secrets/#secrets
406+
*/
407+
public function secrets(): Secrets
408+
{
409+
return new Secrets($this->client);
410+
}
411+
367412
/**
368413
* Manage the content of a repository.
369414
*
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace Github\Api\Repository\Actions;
4+
5+
use Github\Api\AbstractApi;
6+
7+
/**
8+
* @link https://developer.github.com/v3/actions/artifacts/
9+
*/
10+
class Artifacts extends AbstractApi
11+
{
12+
/**
13+
* @link https://developer.github.com/v3/actions/artifacts/#list-artifacts-for-a-repository
14+
*
15+
* @param string $username
16+
* @param string $repository
17+
* @param array $parameters
18+
*
19+
* @return array
20+
*/
21+
public function all(string $username, string $repository, array $parameters = [])
22+
{
23+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts', $parameters);
24+
}
25+
26+
/**
27+
* @link https://developer.github.com/v3/actions/artifacts/#list-workflow-run-artifacts
28+
*
29+
* @param string $username
30+
* @param string $repository
31+
* @param int $runId
32+
*
33+
* @return array
34+
*/
35+
public function runArtifacts(string $username, string $repository, int $runId)
36+
{
37+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/artifacts');
38+
}
39+
40+
/**
41+
* @link https://developer.github.com/v3/actions/artifacts/#get-an-artifact
42+
*
43+
* @param string $username
44+
* @param string $repository
45+
* @param int $artifactId
46+
*
47+
* @return array
48+
*/
49+
public function show(string $username, string $repository, int $artifactId)
50+
{
51+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId);
52+
}
53+
54+
/**
55+
* @link https://developer.github.com/v3/actions/artifacts/#download-an-artifact
56+
*
57+
* @param string $username
58+
* @param string $repository
59+
* @param int $artifactId
60+
* @param string $format
61+
*
62+
* @return array
63+
*/
64+
public function download(string $username, string $repository, int $artifactId, string $format = 'zip')
65+
{
66+
// TODO(): Get `Location` header for download link.
67+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId.'/'.$format);
68+
}
69+
70+
/**
71+
* @link https://developer.github.com/v3/actions/artifacts/#delete-an-artifact
72+
*
73+
* @param string $username
74+
* @param string $repository
75+
* @param int $artifactId
76+
*
77+
* @return array
78+
*/
79+
public function remove(string $username, string $repository, int $artifactId)
80+
{
81+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId);
82+
}
83+
}

0 commit comments

Comments
 (0)