Skip to content

Commit 5d7048f

Browse files
committed
Merge branch 'master' into feature/deployment-branch-policies
2 parents c30050c + bdb9bfb commit 5d7048f

File tree

21 files changed

+1226
-6
lines changed

21 files changed

+1226
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
14+
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
1515

1616
steps:
1717
- uses: actions/checkout@v3

doc/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ v3 APIs:
3939
* [Organization](organization.md)
4040
* [Members](organization/members.md)
4141
* [Teams](organization/teams.md)
42+
* [Secrets](organization/actions/secrets.md)
43+
* [Variables](organization/actions/variables.md)
4244
* [Projects](project/projects.md)
4345
* [Columns](project/columns.md)
4446
* [Cards](project/cards.md)
@@ -51,6 +53,7 @@ v3 APIs:
5153
* Actions
5254
* [Artifacts](repo/actions/artifacts.md)
5355
* [Secrets](repo/actions/secrets.md)
56+
* [Variables](repo/actions/variables.md)
5457
* [Self hosted runners](repo/actions/self_hosted_runners.md)
5558
* [Workflow jobs](repo/actions/workflow_jobs.md)
5659
* [Workflow runs](repo/actions/workflow_runs.md)
@@ -59,7 +62,9 @@ v3 APIs:
5962
* [Check Suites](repo/check_suites.md)
6063
* [Contents](repo/contents.md)
6164
* [Deployments](repo/deployments.md)
62-
* [Policies](repo/policies.md)
65+
* [Secrets](environment/secrets.md)
66+
* [Variables](environment/variables.md)
67+
* [Policies](repo/policies.md)
6368
* [Environments](repo/environments.md)
6469
* [Labels](repo/labels.md)
6570
* [Protection](repo/protection.md)

doc/environment/secrets.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Environment / Secrets API
2+
[Back to the "Environments API"](../repo/environments.md) | [Back to the navigation](../README.md)
3+
4+
### List environment secrets
5+
6+
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28
7+
8+
```php
9+
$secrets = $client->environment()->secrets()->all($repoId, $envName);
10+
```
11+
12+
### Get an environment secret
13+
14+
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-secret
15+
16+
```php
17+
$secret = $client->environment()->secrets()->show($repoId, $envName, $secretName);
18+
```
19+
20+
### Create or Update an environment secret
21+
22+
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-environment-secret
23+
24+
```php
25+
$client->environment()->secrets()->createOrUpdate($repoId, $envName, $secretName, [
26+
'encrypted_value' => $encryptedValue,
27+
'key_id' => $key_id
28+
]);
29+
```
30+
31+
### Delete an environment secret
32+
33+
https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret
34+
35+
```php
36+
$client->environment()->secrets()->remove($repoId, $envName, $secretName);
37+
```
38+
39+
### Get an environment public key
40+
41+
https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key
42+
43+
```php
44+
$client->environment()->secrets()->publicKey($repoId, $envName);
45+
```
46+

doc/environment/variables.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Environment / Variables API
2+
[Back to the "Environments API"](../repo/environments.md) | [Back to the navigation](../README.md)
3+
4+
### List environment variables
5+
6+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-environment-variables
7+
8+
```php
9+
$variables = $client->environment()->variables()->all($repoId, $envName);
10+
```
11+
12+
### Get an environment variable
13+
14+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable
15+
16+
```php
17+
$variable = $client->environment()->variables()->show($repoId, $envName, $variableName);
18+
```
19+
20+
### Create environment variable
21+
22+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-environment-variable
23+
24+
```php
25+
$client->environment()->variables()->create($repoId, $envName, [
26+
'name' => $name,
27+
'value' => $value
28+
]);
29+
```
30+
31+
### Update environment variable
32+
33+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-environment-variable
34+
35+
```php
36+
$client->environment()->variables()->update($repoId, $envName, $variableName, [
37+
'name' => $name,
38+
'value' => $value
39+
]);
40+
```
41+
42+
### Delete an environment variable
43+
44+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-environment-variable
45+
46+
```php
47+
$client->environment()->variables()->remove($repoId, $envName, $variableName);
48+
```
49+

doc/organization/actions/variables.md

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

doc/repo/actions/variables.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Repo / Actions / Variables API
2+
[Back to the "Repos API"](../../repos.md) | [Back to the navigation](../../README.md)
3+
4+
### List repository variables
5+
6+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables
7+
8+
```php
9+
$variables = $client->api('repo')->variables()->all('KnpLabs', 'php-github-api');
10+
```
11+
12+
### Get a repository variable
13+
14+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable
15+
16+
```php
17+
$variable = $client->api('repo')->variables()->show('KnpLabs', 'php-github-api', $variableName);
18+
```
19+
20+
### Create a repository variable
21+
22+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable
23+
24+
```php
25+
$client->api('repo')->variables()->create('KnpLabs', 'php-github-api', [
26+
'name' => $name,
27+
'value' => $value,
28+
]);
29+
```
30+
31+
### Update a repository variable
32+
33+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable
34+
35+
```php
36+
$client->api('repo')->variables()->update('KnpLabs', 'php-github-api', $variableName, [
37+
'name' => $name,
38+
'value' => $value,
39+
]);
40+
```
41+
42+
### Delete a repository variable
43+
44+
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable
45+
46+
```php
47+
$client->api('repo')->variables()->remove('KnpLabs', 'php-github-api', $variableName);
48+
```

doc/repo/environments.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
Provides information about environments for a repository. Wraps [GitHub Environments API](https://docs.github.com/en/rest/deployments/environments?apiVersion=2022-11-28).
55

6+
Additional APIs:
7+
* [Secrets API](environment/secrets.md)
8+
* [Variables API](environment/variables.md)
9+
610
#### List all environments.
711

812
```php

lib/Github/Api/Deployment/Environments.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Github\Api\AbstractApi;
66

7+
use Github\Api\Environment\Secrets;
8+
use Github\Api\Environment\Variables;
9+
710
/**
811
* Listing, creating and updating environments.
912
*
@@ -38,7 +41,7 @@ public function all($username, $repository, array $params = [])
3841
*/
3942
public function show($username, $repository, $name)
4043
{
41-
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.$name);
44+
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name));
4245
}
4346

4447
/**
@@ -55,7 +58,7 @@ public function show($username, $repository, $name)
5558
*/
5659
public function createOrUpdate($username, $repository, $name, array $params = [])
5760
{
58-
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments', $params);
61+
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name), $params);
5962
}
6063

6164
/**
@@ -67,6 +70,22 @@ public function createOrUpdate($username, $repository, $name, array $params = []
6770
*/
6871
public function remove(string $username, string $repository, string $name)
6972
{
70-
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.$name);
73+
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name));
74+
}
75+
76+
/**
77+
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#about-secrets-in-github-actions
78+
*/
79+
public function secrets(): Secrets
80+
{
81+
return new Secrets($this->getClient());
82+
}
83+
84+
/**
85+
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#about-variables-in-github-actions
86+
*/
87+
public function variables(): Variables
88+
{
89+
return new Variables($this->getClient());
7190
}
7291
}

0 commit comments

Comments
 (0)