Skip to main content
Die REST-API verfügt jetzt über eine Versionskontrolle. Weitere Informationen findest du unter Informationen zur API-Versionsverwaltung.

Richtlinien für Bereitstellungsbranches

Verwende die REST-API, um benutzerdefinierte Richtlinien für Bereitstellungsbranches zu verwalten.

Informationen zu Richtlinien für Bereitstellungsbranches

Du kannst die REST-API verwenden, um benutzerdefinierte Namensmuster anzugeben, mit denen Branches übereinstimmen müssen, damit die Bereitstellung in einer Umgebung funktioniert. Die deployment_branch_policy.custom_branch_policies-Eigenschaft für die Umgebung muss auf true festgelegt werden, um diese Endpunkte zu verwenden. Informationen zum Aktualisieren der deployment_branch_policy für eine Umgebung findest du unter Bereitstellungsumgebungen.

Weitere Informationen zum Einschränken von Umgebungsbereitstellungen auf bestimmte Branches findest du unter Verwenden von Umgebungen für die Bereitstellung.

List deployment branch policies

Funktioniert mit GitHub Apps

Lists the deployment branch policies for an environment.

Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

Parameter für „List deployment branch policies“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Erforderlich

The name of the environment.

Abfrageparameter
Name, type, BESCHREIBUNG
per_page integer

The number of results per page (max 100).

Standard: 30

page integer

Page number of the results to fetch.

Standard: 1

HTTP-Antwortstatuscodes für „List deployment branch policies“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „List deployment branch policies“

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies

Response

Status: 200
{ "total_count": 2, "branch_policies": [ { "id": 361471, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzE=", "name": "release/*" }, { "id": 361472, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjE0NzI=", "name": "main" } ] }

Create a deployment branch policy

Funktioniert mit GitHub Apps

Creates a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

Parameter für „Create a deployment branch policy“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Erforderlich

The name of the environment.

Textparameter
Name, type, BESCHREIBUNG
name string Erforderlich

The name pattern that branches must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

HTTP-Antwortstatuscodes für „Create a deployment branch policy“

StatuscodeBESCHREIBUNG
200

OK

303

Response if the same branch name pattern already exists

404

Not Found or deployment_branch_policy.custom_branch_policies property for the environment is set to false

Codebeispiele für „Create a deployment branch policy“

post/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies \ -d '{"name":"release/*"}'

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Get a deployment branch policy

Funktioniert mit GitHub Apps

Gets a deployment branch policy for an environment.

Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

Parameter für „Get a deployment branch policy“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Erforderlich

The name of the environment.

branch_policy_id integer Erforderlich

The unique identifier of the branch policy.

HTTP-Antwortstatuscodes für „Get a deployment branch policy“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „Get a deployment branch policy“

get/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Update a deployment branch policy

Funktioniert mit GitHub Apps

Updates a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

Parameter für „Update a deployment branch policy“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Erforderlich

The name of the environment.

branch_policy_id integer Erforderlich

The unique identifier of the branch policy.

Textparameter
Name, type, BESCHREIBUNG
name string Erforderlich

The name pattern that branches must match in order to deploy to the environment.

Wildcard characters will not match /. For example, to match branches that begin with release/ and contain an additional single slash, use release/*/*. For more information about pattern matching syntax, see the Ruby File.fnmatch documentation.

HTTP-Antwortstatuscodes für „Update a deployment branch policy“

StatuscodeBESCHREIBUNG
200

OK

Codebeispiele für „Update a deployment branch policy“

put/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID \ -d '{"name":"release/*"}'

Response

Status: 200
{ "id": 364662, "node_id": "MDE2OkdhdGVCcmFuY2hQb2xpY3kzNjQ2NjI=", "name": "release/*" }

Delete a deployment branch policy

Funktioniert mit GitHub Apps

Deletes a deployment branch policy for an environment.

You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the administration:write permission for the repository to use this endpoint.

Parameter für „Delete a deployment branch policy“

Header
Name, type, BESCHREIBUNG
accept string

Setting to application/vnd.github+json is recommended.

Pfadparameter
Name, type, BESCHREIBUNG
owner string Erforderlich

The account owner of the repository. The name is not case sensitive.

repo string Erforderlich

The name of the repository without the .git extension. The name is not case sensitive.

environment_name string Erforderlich

The name of the environment.

branch_policy_id integer Erforderlich

The unique identifier of the branch policy.

HTTP-Antwortstatuscodes für „Delete a deployment branch policy“

StatuscodeBESCHREIBUNG
204

No Content

Codebeispiele für „Delete a deployment branch policy“

delete/repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/environments/ENVIRONMENT_NAME/deployment-branch-policies/BRANCH_POLICY_ID

Response

Status: 204