-
-
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 #1108 Deployment branch policies (Froxz)
This PR was squashed before being merged into the 3.10.x-dev branch. Discussion ---------- * added Deployment branch policies * Moved environments under deployment Commits ------- 9734d23 Deployment branch policies c72fdae removed params validation a61fe84 StyleCI fixes c30050c styleCI fixes 5d7048f Merge branch 'master' into feature/deployment-branch-policies f657c3f StyleCi fixes d9f0195 Changes to docs
- Loading branch information
Showing
13 changed files
with
309 additions
and
46 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
2 changes: 1 addition & 1 deletion
2
doc/environment/secrets.md → doc/repo/deployments/environment/secrets.md
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
2 changes: 1 addition & 1 deletion
2
doc/environment/variables.md → ...repo/deployments/environment/variables.md
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,32 @@ | ||
## Deployment / Environments API | ||
[Back to the "Deployment API"](../deployments.md) | [Back to the navigation](../index.md) | ||
|
||
Provides information about environments for a repository. Wraps [GitHub Environments API](https://docs.github.com/en/rest/deployments/environments?apiVersion=2022-11-28). | ||
|
||
Additional APIs: | ||
* [Secrets API](environment/secrets.md) | ||
* [Variables API](environment/variables.md) | ||
|
||
#### List all environments. | ||
|
||
```php | ||
$environments = $client->deployment()->environment()->all('KnpLabs', 'php-github-api'); | ||
``` | ||
|
||
### Get one environment. | ||
|
||
```php | ||
$environment = $client->deployment()->environment()->show('KnpLabs', 'php-github-api', $name); | ||
``` | ||
|
||
#### Create or update environment. | ||
|
||
```php | ||
$data = $client->deployment()->environment()->createOrUpdate('KnpLabs', 'php-github-api', $name); | ||
``` | ||
|
||
#### Delete a existing environment. | ||
|
||
```php | ||
$environment = $client->deployment()->environment()->remove('KnpLabs', 'php-github-api', $name); | ||
``` |
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,38 @@ | ||
## Deployment / Branch policies API | ||
[Back to the "Deployment API"](../deployments.md) | [Back to the navigation](../index.md) | ||
|
||
Provides information about deployment branch policies. Wraps [GitHub Deployment branch policies API](https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#about-deployment-branch-policies). | ||
|
||
#### List deployment branch policies. | ||
|
||
```php | ||
$policies = $client->deployment()->policies()->all('KnpLabs', 'php-github-api', 'production'); | ||
``` | ||
|
||
### Get one environment. | ||
|
||
```php | ||
$policy = $client->deployment()->policies()->show('KnpLabs', 'php-github-api', 'production', $branchPolicyId); | ||
``` | ||
|
||
#### Create policy. | ||
|
||
```php | ||
$data = $client->deployment()->policies()->create('KnpLabs', 'php-github-api', 'production', [ | ||
'name' => 'name' | ||
]); | ||
``` | ||
|
||
#### Update policy. | ||
|
||
```php | ||
$data = $client->deployment()->policies()->update('KnpLabs', 'php-github-api', 'production', $branchPolicyId, [ | ||
'name' => 'name' | ||
]); | ||
``` | ||
|
||
#### Delete a existing policy. | ||
|
||
```php | ||
$policy = $client->deployment()->policies()->remove('KnpLabs', 'php-github-api', 'production', $branchPolicyId); | ||
``` |
This file was deleted.
Oops, something went wrong.
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,97 @@ | ||
<?php | ||
|
||
namespace Github\Api\Deployment; | ||
|
||
use Github\Api\AbstractApi; | ||
|
||
/** | ||
* Listing, creating and updating deployments. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#list-deployment-branch-policies | ||
*/ | ||
class Policies extends AbstractApi | ||
{ | ||
/** | ||
* List deployment branch policies. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#list-deployment-branch-policies | ||
* | ||
* @param string $username the username of the user who owns the repository | ||
* @param string $repository the name of the repository | ||
* @param string $environment the name of the environment. | ||
* @param array $params query parameters to filter deployments by (see link) | ||
* | ||
* @return array the branch policies requested | ||
*/ | ||
public function all(string $username, string $repository, string $environment, array $params = []) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies', $params); | ||
} | ||
|
||
/** | ||
* Get a deployment branch policy. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#get-a-deployment-branch-policy | ||
* | ||
* @param string $username the username of the user who owns the repository | ||
* @param string $repository the name of the repository | ||
* @param string $environment the name of the environment. | ||
* @param int $id the unique identifier of the branch policy. | ||
* | ||
* @return array | ||
*/ | ||
public function show(string $username, string $repository, string $environment, int $id) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id); | ||
} | ||
|
||
/** | ||
* Creates a deployment branch policy for an environment. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#create-a-deployment-branch-policy | ||
* | ||
* @param string $username the username of the user who owns the repository | ||
* @param string $repository the name of the repository | ||
* @param string $environment the name of the environment. | ||
* | ||
* @return array information about the deployment branch policy | ||
*/ | ||
public function create(string $username, string $repository, string $environment, array $params) | ||
{ | ||
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies', $params); | ||
} | ||
|
||
/** | ||
* Updates a deployment branch policy for an environment. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#update-a-deployment-branch-policy | ||
* | ||
* @param string $username the username of the user who owns the repository | ||
* @param string $repository the name of the repository | ||
* @param string $environment the name of the environment. | ||
* @param int $id the unique identifier of the branch policy. | ||
* | ||
* @return array information about the deployment branch policy | ||
*/ | ||
public function update(string $username, string $repository, string $environment, int $id, array $params) | ||
{ | ||
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id, $params); | ||
} | ||
|
||
/** | ||
* Delete a deployment branch policy. | ||
* | ||
* @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#delete-a-deployment-branch-policy | ||
* | ||
* @param string $username the username of the user who owns the repository | ||
* @param string $repository the name of the repository | ||
* @param string $environment the name of the environment. | ||
* @param int $id the unique identifier of the branch policy. | ||
* | ||
* @return mixed null on success, array on error with 'message' | ||
*/ | ||
public function remove(string $username, string $repository, string $environment, int $id) | ||
{ | ||
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id); | ||
} | ||
} |
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
Oops, something went wrong.