Skip to content

Commit c81fadb

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
1 parent 562ca30 commit c81fadb

File tree

12 files changed

+970
-0
lines changed

12 files changed

+970
-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/Repo.php

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

33
namespace Github\Api;
44

5+
use Github\Api\Repository\Actions\Artifacts;
6+
use Github\Api\Repository\Actions\WorkflowJobs;
7+
use Github\Api\Repository\Actions\WorkflowRuns;
8+
use Github\Api\Repository\Actions\Workflows;
59
use Github\Api\Repository\Checks;
610
use Github\Api\Repository\Checks\CheckRuns;
711
use Github\Api\Repository\Checks\CheckSuites;
@@ -364,6 +368,38 @@ public function checkSuites(): CheckSuites
364368
return new CheckSuites($this->client);
365369
}
366370

371+
/**
372+
* @link https://developer.github.com/v3/actions/artifacts/#artifacts
373+
*/
374+
public function artifacts(): Artifacts
375+
{
376+
return new Artifacts($this->client);
377+
}
378+
379+
/**
380+
* @link https://developer.github.com/v3/actions/workflows/#workflows
381+
*/
382+
public function workflows(): Workflows
383+
{
384+
return new Workflows($this->client);
385+
}
386+
387+
/**
388+
* @link https://developer.github.com/v3/actions/workflow-runs/#workflow-runs
389+
*/
390+
public function workflowRuns(): WorkflowRuns
391+
{
392+
return new WorkflowRuns($this->client);
393+
}
394+
395+
/**
396+
* @link https://developer.github.com/v3/actions/workflow-jobs/#workflow-jobs
397+
*/
398+
public function workflowJobs(): WorkflowJobs
399+
{
400+
return new WorkflowJobs($this->client);
401+
}
402+
367403
/**
368404
* Manage the content of a repository.
369405
*
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+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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/self-hosted-runners/#self-hosted-runners
9+
*/
10+
class SelfHostedRunners extends AbstractApi
11+
{
12+
/**
13+
* @link https://developer.github.com/v3/actions/self-hosted-runners/#list-self-hosted-runners-for-a-repository
14+
*
15+
* @param string $username
16+
* @param string $repository
17+
*
18+
* @return array|string
19+
*/
20+
public function all(string $username, string $repository)
21+
{
22+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners');
23+
}
24+
25+
/**
26+
* @link https://developer.github.com/v3/actions/self-hosted-runners/#get-a-self-hosted-runner-for-a-repository
27+
*
28+
* @param string $username
29+
* @param string $repository
30+
* @param int $runnerId
31+
*
32+
* @return array|string
33+
*/
34+
public function show(string $username, string $repository, int $runnerId)
35+
{
36+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId);
37+
}
38+
39+
/**
40+
* @link https://developer.github.com/v3/actions/self-hosted-runners/#delete-a-self-hosted-runner-from-a-repository
41+
*
42+
* @param string $username
43+
* @param string $repository
44+
* @param int $runnerId
45+
*
46+
* @return array|string
47+
*/
48+
public function remove(string $username, string $repository, int $runnerId)
49+
{
50+
return $this->delete('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId);
51+
}
52+
53+
/**
54+
* @link https://developer.github.com/v3/actions/self-hosted-runners/#list-runner-applications-for-a-repository
55+
*
56+
* @param string $username
57+
* @param string $repository
58+
*
59+
* @return array|string
60+
*/
61+
public function applications(string $username, string $repository)
62+
{
63+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runners/downloads');
64+
}
65+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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/workflow-jobs/
9+
*/
10+
class WorkflowJobs extends AbstractApi
11+
{
12+
/**
13+
* @link https://developer.github.com/v3/actions/workflow-jobs/#list-jobs-for-a-workflow-run
14+
*
15+
* @param string $username
16+
* @param string $repository
17+
* @param int $runId
18+
* @param array $parameters
19+
*
20+
* @return array
21+
*/
22+
public function all(string $username, string $repository, int $runId, array $parameters = [])
23+
{
24+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/jobs', $parameters);
25+
}
26+
27+
/**
28+
* @link https://developer.github.com/v3/actions/workflow-jobs/#get-a-job-for-a-workflow-run
29+
*
30+
* @param string $username
31+
* @param string $repository
32+
* @param int $jobId
33+
*
34+
* @return array
35+
*/
36+
public function show(string $username, string $repository, int $jobId)
37+
{
38+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId);
39+
}
40+
41+
/**
42+
* @link https://developer.github.com/v3/actions/workflow-jobs/#download-job-logs-for-a-workflow-run
43+
*
44+
* @param string $username
45+
* @param string $repository
46+
* @param int $jobId
47+
*
48+
* @return array
49+
*/
50+
public function downloadLogs(string $username, string $repository, int $jobId)
51+
{
52+
// TODO(): Get `Location` header for download link.
53+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId.'/logs');
54+
}
55+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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/workflow-runs/#workflow-runs
9+
*/
10+
class WorkflowRuns extends AbstractApi
11+
{
12+
/**
13+
* @link https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs-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/runs', $parameters);
24+
}
25+
26+
/**
27+
* @link https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
28+
*
29+
* @param string $username
30+
* @param string $repository
31+
* @param string $workflowId
32+
* @param array $parameters
33+
*
34+
* @return array
35+
*/
36+
public function listRuns(string $username, string $repository, string $workflowId, array $parameters = [])
37+
{
38+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflowId.'/runs', $parameters);
39+
}
40+
41+
/**
42+
* @link https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
43+
*
44+
* @param string $username
45+
* @param string $repository
46+
* @param int $runId
47+
* @param array $parameters
48+
*
49+
* @return array
50+
*/
51+
public function show(string $username, string $repository, int $runId, array $parameters = [])
52+
{
53+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId, $parameters);
54+
}
55+
56+
/**
57+
* @link https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
58+
*
59+
* @param string $username
60+
* @param string $repository
61+
* @param int $runId
62+
*
63+
* @return array
64+
*/
65+
public function rerun(string $username, string $repository, int $runId)
66+
{
67+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/rerun');
68+
}
69+
70+
/**
71+
* @link https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
72+
*
73+
* @param string $username
74+
* @param string $repository
75+
* @param int $runId
76+
*
77+
* @return array
78+
*/
79+
public function cancel(string $username, string $repository, int $runId)
80+
{
81+
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/cancel');
82+
}
83+
84+
/**
85+
* @link https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
86+
*
87+
* @param string $username
88+
* @param string $repository
89+
* @param int $runId
90+
*
91+
* @return array
92+
*/
93+
public function usage(string $username, string $repository, int $runId)
94+
{
95+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/timing');
96+
}
97+
98+
/**
99+
* @link https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
100+
*
101+
* @param string $username
102+
* @param string $repository
103+
* @param int $runId
104+
*
105+
* @return array|string
106+
*/
107+
public function downloadLogs(string $username, string $repository, int $runId)
108+
{
109+
// TODO(): Get `Location` header for download link.
110+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs');
111+
}
112+
113+
/**
114+
* @link https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
115+
*
116+
* @param string $username
117+
* @param string $repository
118+
* @param int $runId
119+
*
120+
* @return array|string
121+
*/
122+
public function remove(string $username, string $repository, int $runId)
123+
{
124+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs');
125+
}
126+
}

0 commit comments

Comments
 (0)