github.RepositoryEnvironment
Explore with Pulumi AI
This resource allows you to create and manage environments for a GitHub repository.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const current = github.getUser({
    username: "",
});
const example = new github.Repository("example", {
    name: "A Repository Project",
    description: "My awesome codebase",
});
const exampleRepositoryEnvironment = new github.RepositoryEnvironment("example", {
    environment: "example",
    repository: example.name,
    preventSelfReview: true,
    reviewers: [{
        users: [current.then(current => current.id)],
    }],
    deploymentBranchPolicy: {
        protectedBranches: true,
        customBranchPolicies: false,
    },
});
import pulumi
import pulumi_github as github
current = github.get_user(username="")
example = github.Repository("example",
    name="A Repository Project",
    description="My awesome codebase")
example_repository_environment = github.RepositoryEnvironment("example",
    environment="example",
    repository=example.name,
    prevent_self_review=True,
    reviewers=[{
        "users": [current.id],
    }],
    deployment_branch_policy={
        "protected_branches": True,
        "custom_branch_policies": False,
    })
package main
import (
	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		current, err := github.GetUser(ctx, &github.GetUserArgs{
			Username: "",
		}, nil)
		if err != nil {
			return err
		}
		example, err := github.NewRepository(ctx, "example", &github.RepositoryArgs{
			Name:        pulumi.String("A Repository Project"),
			Description: pulumi.String("My awesome codebase"),
		})
		if err != nil {
			return err
		}
		_, err = github.NewRepositoryEnvironment(ctx, "example", &github.RepositoryEnvironmentArgs{
			Environment:       pulumi.String("example"),
			Repository:        example.Name,
			PreventSelfReview: pulumi.Bool(true),
			Reviewers: github.RepositoryEnvironmentReviewerArray{
				&github.RepositoryEnvironmentReviewerArgs{
					Users: pulumi.IntArray{
						pulumi.String(current.Id),
					},
				},
			},
			DeploymentBranchPolicy: &github.RepositoryEnvironmentDeploymentBranchPolicyArgs{
				ProtectedBranches:    pulumi.Bool(true),
				CustomBranchPolicies: pulumi.Bool(false),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() => 
{
    var current = Github.GetUser.Invoke(new()
    {
        Username = "",
    });
    var example = new Github.Repository("example", new()
    {
        Name = "A Repository Project",
        Description = "My awesome codebase",
    });
    var exampleRepositoryEnvironment = new Github.RepositoryEnvironment("example", new()
    {
        Environment = "example",
        Repository = example.Name,
        PreventSelfReview = true,
        Reviewers = new[]
        {
            new Github.Inputs.RepositoryEnvironmentReviewerArgs
            {
                Users = new[]
                {
                    current.Apply(getUserResult => getUserResult.Id),
                },
            },
        },
        DeploymentBranchPolicy = new Github.Inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs
        {
            ProtectedBranches = true,
            CustomBranchPolicies = false,
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.GithubFunctions;
import com.pulumi.github.inputs.GetUserArgs;
import com.pulumi.github.Repository;
import com.pulumi.github.RepositoryArgs;
import com.pulumi.github.RepositoryEnvironment;
import com.pulumi.github.RepositoryEnvironmentArgs;
import com.pulumi.github.inputs.RepositoryEnvironmentReviewerArgs;
import com.pulumi.github.inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
    public static void stack(Context ctx) {
        final var current = GithubFunctions.getUser(GetUserArgs.builder()
            .username("")
            .build());
        var example = new Repository("example", RepositoryArgs.builder()
            .name("A Repository Project")
            .description("My awesome codebase")
            .build());
        var exampleRepositoryEnvironment = new RepositoryEnvironment("exampleRepositoryEnvironment", RepositoryEnvironmentArgs.builder()
            .environment("example")
            .repository(example.name())
            .preventSelfReview(true)
            .reviewers(RepositoryEnvironmentReviewerArgs.builder()
                .users(current.id())
                .build())
            .deploymentBranchPolicy(RepositoryEnvironmentDeploymentBranchPolicyArgs.builder()
                .protectedBranches(true)
                .customBranchPolicies(false)
                .build())
            .build());
    }
}
resources:
  example:
    type: github:Repository
    properties:
      name: A Repository Project
      description: My awesome codebase
  exampleRepositoryEnvironment:
    type: github:RepositoryEnvironment
    name: example
    properties:
      environment: example
      repository: ${example.name}
      preventSelfReview: true
      reviewers:
        - users:
            - ${current.id}
      deploymentBranchPolicy:
        protectedBranches: true
        customBranchPolicies: false
variables:
  current:
    fn::invoke:
      function: github:getUser
      arguments:
        username: ""
Create RepositoryEnvironment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RepositoryEnvironment(name: string, args: RepositoryEnvironmentArgs, opts?: CustomResourceOptions);@overload
def RepositoryEnvironment(resource_name: str,
                          args: RepositoryEnvironmentArgs,
                          opts: Optional[ResourceOptions] = None)
@overload
def RepositoryEnvironment(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          environment: Optional[str] = None,
                          repository: Optional[str] = None,
                          can_admins_bypass: Optional[bool] = None,
                          deployment_branch_policy: Optional[RepositoryEnvironmentDeploymentBranchPolicyArgs] = None,
                          prevent_self_review: Optional[bool] = None,
                          reviewers: Optional[Sequence[RepositoryEnvironmentReviewerArgs]] = None,
                          wait_timer: Optional[int] = None)func NewRepositoryEnvironment(ctx *Context, name string, args RepositoryEnvironmentArgs, opts ...ResourceOption) (*RepositoryEnvironment, error)public RepositoryEnvironment(string name, RepositoryEnvironmentArgs args, CustomResourceOptions? opts = null)
public RepositoryEnvironment(String name, RepositoryEnvironmentArgs args)
public RepositoryEnvironment(String name, RepositoryEnvironmentArgs args, CustomResourceOptions options)
type: github:RepositoryEnvironment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args RepositoryEnvironmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RepositoryEnvironmentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RepositoryEnvironmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RepositoryEnvironmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RepositoryEnvironmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var repositoryEnvironmentResource = new Github.RepositoryEnvironment("repositoryEnvironmentResource", new()
{
    Environment = "string",
    Repository = "string",
    CanAdminsBypass = false,
    DeploymentBranchPolicy = new Github.Inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs
    {
        CustomBranchPolicies = false,
        ProtectedBranches = false,
    },
    PreventSelfReview = false,
    Reviewers = new[]
    {
        new Github.Inputs.RepositoryEnvironmentReviewerArgs
        {
            Teams = new[]
            {
                0,
            },
            Users = new[]
            {
                0,
            },
        },
    },
    WaitTimer = 0,
});
example, err := github.NewRepositoryEnvironment(ctx, "repositoryEnvironmentResource", &github.RepositoryEnvironmentArgs{
	Environment:     pulumi.String("string"),
	Repository:      pulumi.String("string"),
	CanAdminsBypass: pulumi.Bool(false),
	DeploymentBranchPolicy: &github.RepositoryEnvironmentDeploymentBranchPolicyArgs{
		CustomBranchPolicies: pulumi.Bool(false),
		ProtectedBranches:    pulumi.Bool(false),
	},
	PreventSelfReview: pulumi.Bool(false),
	Reviewers: github.RepositoryEnvironmentReviewerArray{
		&github.RepositoryEnvironmentReviewerArgs{
			Teams: pulumi.IntArray{
				pulumi.Int(0),
			},
			Users: pulumi.IntArray{
				pulumi.Int(0),
			},
		},
	},
	WaitTimer: pulumi.Int(0),
})
var repositoryEnvironmentResource = new RepositoryEnvironment("repositoryEnvironmentResource", RepositoryEnvironmentArgs.builder()
    .environment("string")
    .repository("string")
    .canAdminsBypass(false)
    .deploymentBranchPolicy(RepositoryEnvironmentDeploymentBranchPolicyArgs.builder()
        .customBranchPolicies(false)
        .protectedBranches(false)
        .build())
    .preventSelfReview(false)
    .reviewers(RepositoryEnvironmentReviewerArgs.builder()
        .teams(0)
        .users(0)
        .build())
    .waitTimer(0)
    .build());
repository_environment_resource = github.RepositoryEnvironment("repositoryEnvironmentResource",
    environment="string",
    repository="string",
    can_admins_bypass=False,
    deployment_branch_policy={
        "custom_branch_policies": False,
        "protected_branches": False,
    },
    prevent_self_review=False,
    reviewers=[{
        "teams": [0],
        "users": [0],
    }],
    wait_timer=0)
const repositoryEnvironmentResource = new github.RepositoryEnvironment("repositoryEnvironmentResource", {
    environment: "string",
    repository: "string",
    canAdminsBypass: false,
    deploymentBranchPolicy: {
        customBranchPolicies: false,
        protectedBranches: false,
    },
    preventSelfReview: false,
    reviewers: [{
        teams: [0],
        users: [0],
    }],
    waitTimer: 0,
});
type: github:RepositoryEnvironment
properties:
    canAdminsBypass: false
    deploymentBranchPolicy:
        customBranchPolicies: false
        protectedBranches: false
    environment: string
    preventSelfReview: false
    repository: string
    reviewers:
        - teams:
            - 0
          users:
            - 0
    waitTimer: 0
RepositoryEnvironment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The RepositoryEnvironment resource accepts the following input properties:
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- CanAdmins boolBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- DeploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- PreventSelf boolReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- Reviewers
List<RepositoryEnvironment Reviewer> 
- The environment reviewers configuration.
- WaitTimer int
- Amount of time to delay a job after the job is initially triggered.
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- CanAdmins boolBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- DeploymentBranch RepositoryPolicy Environment Deployment Branch Policy Args 
- The deployment branch policy configuration
- PreventSelf boolReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- Reviewers
[]RepositoryEnvironment Reviewer Args 
- The environment reviewers configuration.
- WaitTimer int
- Amount of time to delay a job after the job is initially triggered.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
- canAdmins BooleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- preventSelf BooleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- reviewers
List<RepositoryEnvironment Reviewer> 
- The environment reviewers configuration.
- waitTimer Integer
- Amount of time to delay a job after the job is initially triggered.
- environment string
- The name of the environment.
- repository string
- The repository of the environment.
- canAdmins booleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- preventSelf booleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- reviewers
RepositoryEnvironment Reviewer[] 
- The environment reviewers configuration.
- waitTimer number
- Amount of time to delay a job after the job is initially triggered.
- environment str
- The name of the environment.
- repository str
- The repository of the environment.
- can_admins_ boolbypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deployment_branch_ Repositorypolicy Environment Deployment Branch Policy Args 
- The deployment branch policy configuration
- prevent_self_ boolreview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- reviewers
Sequence[RepositoryEnvironment Reviewer Args] 
- The environment reviewers configuration.
- wait_timer int
- Amount of time to delay a job after the job is initially triggered.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
- canAdmins BooleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch Property MapPolicy 
- The deployment branch policy configuration
- preventSelf BooleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- reviewers List<Property Map>
- The environment reviewers configuration.
- waitTimer Number
- Amount of time to delay a job after the job is initially triggered.
Outputs
All input properties are implicitly available as output properties. Additionally, the RepositoryEnvironment resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing RepositoryEnvironment Resource
Get an existing RepositoryEnvironment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RepositoryEnvironmentState, opts?: CustomResourceOptions): RepositoryEnvironment@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        can_admins_bypass: Optional[bool] = None,
        deployment_branch_policy: Optional[RepositoryEnvironmentDeploymentBranchPolicyArgs] = None,
        environment: Optional[str] = None,
        prevent_self_review: Optional[bool] = None,
        repository: Optional[str] = None,
        reviewers: Optional[Sequence[RepositoryEnvironmentReviewerArgs]] = None,
        wait_timer: Optional[int] = None) -> RepositoryEnvironmentfunc GetRepositoryEnvironment(ctx *Context, name string, id IDInput, state *RepositoryEnvironmentState, opts ...ResourceOption) (*RepositoryEnvironment, error)public static RepositoryEnvironment Get(string name, Input<string> id, RepositoryEnvironmentState? state, CustomResourceOptions? opts = null)public static RepositoryEnvironment get(String name, Output<String> id, RepositoryEnvironmentState state, CustomResourceOptions options)resources:  _:    type: github:RepositoryEnvironment    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- CanAdmins boolBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- DeploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- Environment string
- The name of the environment.
- PreventSelf boolReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- Repository string
- The repository of the environment.
- Reviewers
List<RepositoryEnvironment Reviewer> 
- The environment reviewers configuration.
- WaitTimer int
- Amount of time to delay a job after the job is initially triggered.
- CanAdmins boolBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- DeploymentBranch RepositoryPolicy Environment Deployment Branch Policy Args 
- The deployment branch policy configuration
- Environment string
- The name of the environment.
- PreventSelf boolReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- Repository string
- The repository of the environment.
- Reviewers
[]RepositoryEnvironment Reviewer Args 
- The environment reviewers configuration.
- WaitTimer int
- Amount of time to delay a job after the job is initially triggered.
- canAdmins BooleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- environment String
- The name of the environment.
- preventSelf BooleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- repository String
- The repository of the environment.
- reviewers
List<RepositoryEnvironment Reviewer> 
- The environment reviewers configuration.
- waitTimer Integer
- Amount of time to delay a job after the job is initially triggered.
- canAdmins booleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch RepositoryPolicy Environment Deployment Branch Policy 
- The deployment branch policy configuration
- environment string
- The name of the environment.
- preventSelf booleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- repository string
- The repository of the environment.
- reviewers
RepositoryEnvironment Reviewer[] 
- The environment reviewers configuration.
- waitTimer number
- Amount of time to delay a job after the job is initially triggered.
- can_admins_ boolbypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deployment_branch_ Repositorypolicy Environment Deployment Branch Policy Args 
- The deployment branch policy configuration
- environment str
- The name of the environment.
- prevent_self_ boolreview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- repository str
- The repository of the environment.
- reviewers
Sequence[RepositoryEnvironment Reviewer Args] 
- The environment reviewers configuration.
- wait_timer int
- Amount of time to delay a job after the job is initially triggered.
- canAdmins BooleanBypass 
- Can repository admins bypass the environment protections. Defaults to true.
- deploymentBranch Property MapPolicy 
- The deployment branch policy configuration
- environment String
- The name of the environment.
- preventSelf BooleanReview 
- Whether or not a user who created the job is prevented from approving their own job. Defaults to false.
- repository String
- The repository of the environment.
- reviewers List<Property Map>
- The environment reviewers configuration.
- waitTimer Number
- Amount of time to delay a job after the job is initially triggered.
Supporting Types
RepositoryEnvironmentDeploymentBranchPolicy, RepositoryEnvironmentDeploymentBranchPolicyArgs          
- CustomBranch boolPolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- ProtectedBranches bool
- Whether only branches with branch protection rules can deploy to this environment.
- CustomBranch boolPolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- ProtectedBranches bool
- Whether only branches with branch protection rules can deploy to this environment.
- customBranch BooleanPolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- protectedBranches Boolean
- Whether only branches with branch protection rules can deploy to this environment.
- customBranch booleanPolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- protectedBranches boolean
- Whether only branches with branch protection rules can deploy to this environment.
- custom_branch_ boolpolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- protected_branches bool
- Whether only branches with branch protection rules can deploy to this environment.
- customBranch BooleanPolicies 
- Whether only branches that match the specified name patterns can deploy to this environment.
- protectedBranches Boolean
- Whether only branches with branch protection rules can deploy to this environment.
RepositoryEnvironmentReviewer, RepositoryEnvironmentReviewerArgs      
- Teams List<int>
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- Users List<int>
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- Teams []int
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- Users []int
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- teams List<Integer>
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- users List<Integer>
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- teams number[]
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- users number[]
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- teams Sequence[int]
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- users Sequence[int]
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- teams List<Number>
- Up to 6 IDs for teams who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
- users List<Number>
- Up to 6 IDs for users who may review jobs that reference the environment. Reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
Import
GitHub Repository Environment can be imported using an ID made up of name of the repository combined with the environment name of the environment, separated by a : character, e.g.
$ pulumi import github:index/repositoryEnvironment:RepositoryEnvironment daily terraform:daily
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- GitHub pulumi/pulumi-github
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the githubTerraform Provider.