-
-
Notifications
You must be signed in to change notification settings - Fork 597
Added environment variables & secrets #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7de0912
Added environment variables & secrets
SergkeiM d08d18d
fixes for styleCI
SergkeiM 3f4fff0
removed rawurlencode for repo id
SergkeiM 289c0ab
added link to secrets and varaibles
SergkeiM cbf08fc
Removed validation of parameters
SergkeiM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,91 @@ | ||
<?php | ||
|
||
namespace Github\Api\Environment; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
/** | ||
* @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 | ||
* | ||
* @throws MissingArgumentException | ||
* | ||
* @return array|string | ||
*/ | ||
public function createOrUpdate(int $id, string $name, string $secretName, array $parameters = []) | ||
{ | ||
if (!isset($parameters['encrypted_value'])) { | ||
throw new MissingArgumentException(['encrypted_value']); | ||
} | ||
|
||
if (!isset($parameters['key_id'])) { | ||
throw new MissingArgumentException(['key_id']); | ||
} | ||
|
||
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 hidden or 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,94 @@ | ||
<?php | ||
|
||
namespace Github\Api\Environment; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
/** | ||
* @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 | ||
* | ||
* @throws MissingArgumentException | ||
* | ||
* @return array|string | ||
*/ | ||
public function create(int $id, string $name, array $parameters) | ||
{ | ||
if (!isset($parameters['name'])) { | ||
throw new MissingArgumentException(['name']); | ||
} | ||
|
||
if (!isset($parameters['value'])) { | ||
throw new MissingArgumentException(['value']); | ||
} | ||
SergkeiM marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
* | ||
* @throws MissingArgumentException | ||
* | ||
* @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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.