-
-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #1104 Added environment variables & secrets (Froxz)
This PR was squashed before being merged into the 3.10.x-dev branch. Discussion ---------- Added environment: [Secrets](https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#list-environment-secrets) [Variables](https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-environment-variables) Commits ------- 7de0912 Added environment variables & secrets d08d18d fixes for styleCI 3f4fff0 removed rawurlencode for repo id 289c0ab added link to secrets and varaibles cbf08fc Removed validation of parameters
- Loading branch information
Showing
9 changed files
with
515 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## Environment / Secrets API | ||
[Back to the "Environments API"](../repo/environments.md) | [Back to the navigation](../README.md) | ||
|
||
### List environment secrets | ||
|
||
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28 | ||
|
||
```php | ||
$secrets = $client->environment()->secrets()->all($repoId, $envName); | ||
``` | ||
|
||
### Get an environment secret | ||
|
||
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-secret | ||
|
||
```php | ||
$secret = $client->environment()->secrets()->show($repoId, $envName, $secretName); | ||
``` | ||
|
||
### Create or Update an environment secret | ||
|
||
https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-environment-secret | ||
|
||
```php | ||
$client->environment()->secrets()->createOrUpdate($repoId, $envName, $secretName, [ | ||
'encrypted_value' => $encryptedValue, | ||
'key_id' => $key_id | ||
]); | ||
``` | ||
|
||
### Delete an environment secret | ||
|
||
https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret | ||
|
||
```php | ||
$client->environment()->secrets()->remove($repoId, $envName, $secretName); | ||
``` | ||
|
||
### Get an environment public key | ||
|
||
https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key | ||
|
||
```php | ||
$client->environment()->secrets()->publicKey($repoId, $envName); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Environment / Variables API | ||
[Back to the "Environments API"](../repo/environments.md) | [Back to the navigation](../README.md) | ||
|
||
### List environment variables | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-environment-variables | ||
|
||
```php | ||
$variables = $client->environment()->variables()->all($repoId, $envName); | ||
``` | ||
|
||
### Get an environment variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable | ||
|
||
```php | ||
$variable = $client->environment()->variables()->show($repoId, $envName, $variableName); | ||
``` | ||
|
||
### Create environment variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-environment-variable | ||
|
||
```php | ||
$client->environment()->variables()->create($repoId, $envName, [ | ||
'name' => $name, | ||
'value' => $value | ||
]); | ||
``` | ||
|
||
### Update environment variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-environment-variable | ||
|
||
```php | ||
$client->environment()->variables()->update($repoId, $envName, $variableName, [ | ||
'name' => $name, | ||
'value' => $value | ||
]); | ||
``` | ||
|
||
### Delete an environment variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-environment-variable | ||
|
||
```php | ||
$client->environment()->variables()->remove($repoId, $envName, $variableName); | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Github\Api\Environment; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28 | ||
*/ | ||
class Secrets extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#list-environment-secrets | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* | ||
* @return array|string | ||
*/ | ||
public function all(int $id, string $name) | ||
{ | ||
return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-secret | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $secretName | ||
* | ||
* @return array|string | ||
*/ | ||
public function show(int $id, string $name, string $secretName) | ||
{ | ||
return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-environment-secret | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $secretName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function createOrUpdate(int $id, string $name, string $secretName, array $parameters = []) | ||
{ | ||
return $this->put('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName), $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#delete-an-environment-secret | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $secretName | ||
* | ||
* @return array|string | ||
*/ | ||
public function remove(int $id, string $name, string $secretName) | ||
{ | ||
return $this->delete('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-public-key | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* | ||
* @return array|string | ||
*/ | ||
public function publicKey(int $id, string $name) | ||
{ | ||
return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/public-key'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace Github\Api\Environment; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28 | ||
*/ | ||
class Variables extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-environment-variables | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* | ||
* @return array|string | ||
*/ | ||
public function all(int $id, string $name) | ||
{ | ||
return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function show(int $id, string $name, string $variableName) | ||
{ | ||
return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-environment-variable | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function create(int $id, string $name, array $parameters) | ||
{ | ||
return $this->post('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-environment-variable | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $variableName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function update(int $id, string $name, string $variableName, array $parameters) | ||
{ | ||
return $this->patch('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName), $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-environment-variable | ||
* | ||
* @param int $id | ||
* @param string $name | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function remove(int $id, string $name, string $variableName) | ||
{ | ||
return $this->delete('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); | ||
} | ||
} |
Oops, something went wrong.