-
-
Notifications
You must be signed in to change notification settings - Fork 598
Added Org & Repository variables #1106
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 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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,87 @@ | ||
## Organization / Variables API | ||
[Back to the "Organization API"](../organization.md) | [Back to the navigation](../README.md) | ||
|
||
### List organization variables | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-organization-variables | ||
|
||
```php | ||
$variables = $client->organization()->variables()->all('KnpLabs'); | ||
``` | ||
|
||
### Get an organization variable | ||
|
||
https://docs.github.com/en/rest/reference/actions#get-an-organization-secret | ||
|
||
```php | ||
$variable = $client->organization()->variables()->show('KnpLabs', $variableName); | ||
``` | ||
|
||
### Create an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->create('KnpLabs', [ | ||
'name' => $name, | ||
'value' => $value, | ||
'visibility' => $visibility, | ||
'selected_repository_ids' => $selectedRepositoryIds, | ||
]); | ||
``` | ||
|
||
### Update an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->update('KnpLabs', $variableName, [ | ||
'name' => $name, | ||
'value' => $value, | ||
'visibility' => $visibility, | ||
'selected_repository_ids' => $selectedRepositoryIds | ||
]); | ||
``` | ||
|
||
### Delete an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->remove('KnpLabs', $variableName); | ||
``` | ||
|
||
### List selected repositories for organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->selectedRepositories('KnpLabs', $variableName); | ||
``` | ||
|
||
### Set selected repositories for an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#set-selected-repositories-for-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->setSelectedRepositories('KnpLabs', 'variableName', [ | ||
'selected_repository_ids' => [1, 2, 3], | ||
]); | ||
``` | ||
|
||
### Add selected repository to an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#add-selected-repository-to-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->addRepository('KnpLabs', $repositoryId, $variableName); | ||
``` | ||
|
||
### Remove selected repository from an organization variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-variable | ||
|
||
```php | ||
$client->organization()->variables()->removeRepository('KnpLabs', $repositoryId, $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## Repo / Actions / Variables API | ||
[Back to the "Repos API"](../../repos.md) | [Back to the navigation](../../README.md) | ||
|
||
### List repository variables | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-repository-variables | ||
|
||
```php | ||
$variables = $client->api('repo')->variables()->all('KnpLabs', 'php-github-api'); | ||
``` | ||
|
||
### Get a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable | ||
|
||
```php | ||
$variable = $client->api('repo')->variables()->show('KnpLabs', 'php-github-api', $variableName); | ||
``` | ||
|
||
### Create a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->create('KnpLabs', 'php-github-api', [ | ||
'name' => $name, | ||
'value' => $value, | ||
]); | ||
``` | ||
|
||
### Update a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->update('KnpLabs', 'php-github-api', $variableName, [ | ||
'name' => $name, | ||
'value' => $value, | ||
]); | ||
``` | ||
|
||
### Delete a repository variable | ||
|
||
https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable | ||
|
||
```php | ||
$client->api('repo')->variables()->remove('KnpLabs', 'php-github-api', $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
|
||
namespace Github\Api\Organization\Actions; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/reference/actions#variables | ||
*/ | ||
class Variables extends AbstractApi | ||
{ | ||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-organization-variables | ||
* | ||
* @param string $organization | ||
* | ||
* @return array|string | ||
*/ | ||
public function all(string $organization) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function show(string $organization, string $variableName) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param array $parameters | ||
* | ||
* @throws MissingArgumentException | ||
* | ||
* @return array|string | ||
*/ | ||
public function create(string $organization, array $parameters) | ||
{ | ||
if (!isset($parameters['name'])) { | ||
throw new MissingArgumentException(['name']); | ||
} | ||
|
||
if (!isset($parameters['value'])) { | ||
throw new MissingArgumentException(['value']); | ||
} | ||
|
||
if (!isset($parameters['visibility'])) { | ||
throw new MissingArgumentException(['visibility']); | ||
} | ||
|
||
return $this->post('/orgs/'.rawurlencode($organization).'/actions/variables', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function update(string $organization, string $variableName, array $parameters = []) | ||
{ | ||
return $this->patch('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName), $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function remove(string $organization, string $variableName) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function selectedRepositories(string $organization, string $variableName) | ||
{ | ||
return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories'); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#set-selected-repositories-for-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param string $variableName | ||
* @param array $parameters | ||
* | ||
* @return array|string | ||
*/ | ||
public function setSelectedRepositories(string $organization, string $variableName, array $parameters = []) | ||
{ | ||
if (!isset($parameters['selected_repository_ids'])) { | ||
throw new MissingArgumentException(['selected_repository_ids']); | ||
} | ||
|
||
return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories', $parameters); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#add-selected-repository-to-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param int $repositoryId | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function addRepository(string $organization, int $repositoryId, string $variableName) | ||
{ | ||
return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); | ||
} | ||
|
||
/** | ||
* @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-variable | ||
* | ||
* @param string $organization | ||
* @param int $repositoryId | ||
* @param string $variableName | ||
* | ||
* @return array|string | ||
*/ | ||
public function removeRepository(string $organization, int $repositoryId, string $variableName) | ||
{ | ||
return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); | ||
} | ||
} |
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
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.