saltext.github.utils.gh.environments

Operations on GitHub repository (deployment) environments.

saltext.github.utils.gh.environments.branch_policy_from_patterns(deployment_branches)[source]

Map a deployment_branches specification (all, protected or a list of branch name patterns) onto the API’s deployment_branch_policy setting.

deployment_branches

Which branches can deploy. Either all, protected (branches with branch protection rules) or a list of branch name patterns.

saltext.github.utils.gh.environments.normalize(env)[source]

Extract the managed settings from an environment API payload into a flat mapping with wait_timer, prevent_self_review, reviewers and deployment_branch_policy. The API scatters them over protection_rules entries.

env

Environment payload to normalize.

saltext.github.utils.gh.environments.list_all(conn, repo_name, *, owner=None)[source]

Return all environments of a repository.

conn

GitHubConnection to use.

repo_name

Repository name.

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.environments.get(conn, repo_name, name, *, owner=None)[source]

Return the data of a single environment.

conn

GitHubConnection to use.

repo_name

Repository name.

name

Environment name.

owner

Owner of the repository. Defaults to the connection’s owner.

Raises GitHubNotFoundError if the environment does not exist.

saltext.github.utils.gh.environments.set_(conn, repo_name, name, *, wait_timer=None, prevent_self_review=None, reviewers=None, deployment_branch_policy=None, owner=None)[source]

Create or update an environment, replacing its whole configuration. Unspecified settings are reset to their defaults. Returns the data of the environment.

conn

GitHubConnection to use.

repo_name

Repository name.

name

Environment name.

wait_timer

Amount of time to delay a job after it is initially triggered, in minutes.

prevent_self_review

Prevent a user who created a job from approving it.

reviewers

People or teams that may review jobs that reference the environment, as a list of mappings with type (User or Team) and id.

deployment_branch_policy

Type of deployment branch policy for this environment, either None (default) to allow all branches or a mapping with protected_branches and custom_branch_policies booleans. Branch name patterns for custom policies are managed separately, see create_branch_policy().

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.environments.delete(conn, repo_name, name, *, owner=None)[source]

Delete an environment from a repository.

conn

GitHubConnection to use.

repo_name

Repository name.

name

Environment name.

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.environments.list_branch_policies(conn, repo_name, environment, *, owner=None)[source]

Return all deployment branch policies of an environment.

conn

GitHubConnection to use.

repo_name

Repository name.

environment

Environment name.

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.environments.create_branch_policy(conn, repo_name, environment, name, *, typ='branch', owner=None)[source]

Add a deployment branch (or tag) policy to an environment. Returns the data of the created policy.

The environment’s deployment_branch_policy must have custom_branch_policies enabled.

conn

GitHubConnection to use.

repo_name

Repository name.

environment

Environment name.

name

Name pattern that branches (or tags) must match in order to deploy to the environment.

typ

Target of this rule, either branch or tag. Defaults to branch.

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.environments.delete_branch_policy(conn, repo_name, environment, policy_id, *, owner=None)[source]

Remove a deployment branch policy from an environment.

conn

GitHubConnection to use.

repo_name

Repository name.

environment

Environment name.

policy_id

Branch policy ID.

owner

Owner of the repository. Defaults to the connection’s owner.