branch_restrictions
Creates, updates, deletes, gets or lists a branch_restrictions resource.
Overview
| Name | branch_restrictions |
| Type | Resource |
| Id | github.repos.branch_restrictions |
Fields
The following fields are returned by SELECT queries:
- get_access_restrictions
Response
| Name | Datatype | Description |
|---|---|---|
apps | array | |
apps_url | string (uri) | |
teams | array | |
teams_url | string (uri) | |
url | string (uri) | |
users | array | |
users_url | string (uri) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_access_restrictions | select | owner, repo, branch | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Lists who has access to this protected branch. > [!NOTE] > Users, apps, and teams restrictions are only available for organization-owned repositories. | |
delete_access_restrictions | delete | owner, repo, branch | Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation. Disables the ability to restrict who can push to this branch. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
branch | string | The name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API. |
owner | string | The account owner of the repository. The name is not case sensitive. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
SELECT examples
- get_access_restrictions
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Lists who has access to this protected branch.
> [!NOTE]
> Users, apps, and teams restrictions are only available for organization-owned repositories.
SELECT
apps,
apps_url,
teams,
teams_url,
url,
users,
users_url
FROM github.repos.branch_restrictions
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND branch = '{{ branch }}' -- required
;
DELETE examples
- delete_access_restrictions
Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.
Disables the ability to restrict who can push to this branch.
DELETE FROM github.repos.branch_restrictions
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND branch = '{{ branch }}' --required
;