1. Packages
  2. GitHub
  3. API Docs
  4. RepositoryDeploymentBranchPolicy
GitHub v6.2.2 published on Tuesday, Jun 18, 2024 by Pulumi

github.RepositoryDeploymentBranchPolicy

Explore with Pulumi AI

github logo
GitHub v6.2.2 published on Tuesday, Jun 18, 2024 by Pulumi

    This resource allows you to create and manage deployment branch policies.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const env = new github.RepositoryEnvironment("env", {
        repository: "my_repo",
        environment: "my_env",
        deploymentBranchPolicy: {
            protectedBranches: false,
            customBranchPolicies: true,
        },
    });
    const foo = new github.RepositoryDeploymentBranchPolicy("foo", {
        repository: "my_repo",
        environmentName: "my_env",
        name: "foo",
    }, {
        dependsOn: [env],
    });
    
    import pulumi
    import pulumi_github as github
    
    env = github.RepositoryEnvironment("env",
        repository="my_repo",
        environment="my_env",
        deployment_branch_policy=github.RepositoryEnvironmentDeploymentBranchPolicyArgs(
            protected_branches=False,
            custom_branch_policies=True,
        ))
    foo = github.RepositoryDeploymentBranchPolicy("foo",
        repository="my_repo",
        environment_name="my_env",
        name="foo",
        opts=pulumi.ResourceOptions(depends_on=[env]))
    
    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 {
    		env, err := github.NewRepositoryEnvironment(ctx, "env", &github.RepositoryEnvironmentArgs{
    			Repository:  pulumi.String("my_repo"),
    			Environment: pulumi.String("my_env"),
    			DeploymentBranchPolicy: &github.RepositoryEnvironmentDeploymentBranchPolicyArgs{
    				ProtectedBranches:    pulumi.Bool(false),
    				CustomBranchPolicies: pulumi.Bool(true),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = github.NewRepositoryDeploymentBranchPolicy(ctx, "foo", &github.RepositoryDeploymentBranchPolicyArgs{
    			Repository:      pulumi.String("my_repo"),
    			EnvironmentName: pulumi.String("my_env"),
    			Name:            pulumi.String("foo"),
    		}, pulumi.DependsOn([]pulumi.Resource{
    			env,
    		}))
    		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 env = new Github.RepositoryEnvironment("env", new()
        {
            Repository = "my_repo",
            Environment = "my_env",
            DeploymentBranchPolicy = new Github.Inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs
            {
                ProtectedBranches = false,
                CustomBranchPolicies = true,
            },
        });
    
        var foo = new Github.RepositoryDeploymentBranchPolicy("foo", new()
        {
            Repository = "my_repo",
            EnvironmentName = "my_env",
            Name = "foo",
        }, new CustomResourceOptions
        {
            DependsOn =
            {
                env,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.RepositoryEnvironment;
    import com.pulumi.github.RepositoryEnvironmentArgs;
    import com.pulumi.github.inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs;
    import com.pulumi.github.RepositoryDeploymentBranchPolicy;
    import com.pulumi.github.RepositoryDeploymentBranchPolicyArgs;
    import com.pulumi.resources.CustomResourceOptions;
    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) {
            var env = new RepositoryEnvironment("env", RepositoryEnvironmentArgs.builder()
                .repository("my_repo")
                .environment("my_env")
                .deploymentBranchPolicy(RepositoryEnvironmentDeploymentBranchPolicyArgs.builder()
                    .protectedBranches(false)
                    .customBranchPolicies(true)
                    .build())
                .build());
    
            var foo = new RepositoryDeploymentBranchPolicy("foo", RepositoryDeploymentBranchPolicyArgs.builder()
                .repository("my_repo")
                .environmentName("my_env")
                .name("foo")
                .build(), CustomResourceOptions.builder()
                    .dependsOn(env)
                    .build());
    
        }
    }
    
    resources:
      env:
        type: github:RepositoryEnvironment
        properties:
          repository: my_repo
          environment: my_env
          deploymentBranchPolicy:
            protectedBranches: false
            customBranchPolicies: true
      foo:
        type: github:RepositoryDeploymentBranchPolicy
        properties:
          repository: my_repo
          environmentName: my_env
          name: foo
        options:
          dependson:
            - ${env}
    

    Create RepositoryDeploymentBranchPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new RepositoryDeploymentBranchPolicy(name: string, args: RepositoryDeploymentBranchPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def RepositoryDeploymentBranchPolicy(resource_name: str,
                                         args: RepositoryDeploymentBranchPolicyArgs,
                                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def RepositoryDeploymentBranchPolicy(resource_name: str,
                                         opts: Optional[ResourceOptions] = None,
                                         environment_name: Optional[str] = None,
                                         repository: Optional[str] = None,
                                         name: Optional[str] = None)
    func NewRepositoryDeploymentBranchPolicy(ctx *Context, name string, args RepositoryDeploymentBranchPolicyArgs, opts ...ResourceOption) (*RepositoryDeploymentBranchPolicy, error)
    public RepositoryDeploymentBranchPolicy(string name, RepositoryDeploymentBranchPolicyArgs args, CustomResourceOptions? opts = null)
    public RepositoryDeploymentBranchPolicy(String name, RepositoryDeploymentBranchPolicyArgs args)
    public RepositoryDeploymentBranchPolicy(String name, RepositoryDeploymentBranchPolicyArgs args, CustomResourceOptions options)
    
    type: github:RepositoryDeploymentBranchPolicy
    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 RepositoryDeploymentBranchPolicyArgs
    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 RepositoryDeploymentBranchPolicyArgs
    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 RepositoryDeploymentBranchPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RepositoryDeploymentBranchPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RepositoryDeploymentBranchPolicyArgs
    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 repositoryDeploymentBranchPolicyResource = new Github.RepositoryDeploymentBranchPolicy("repositoryDeploymentBranchPolicyResource", new()
    {
        EnvironmentName = "string",
        Repository = "string",
        Name = "string",
    });
    
    example, err := github.NewRepositoryDeploymentBranchPolicy(ctx, "repositoryDeploymentBranchPolicyResource", &github.RepositoryDeploymentBranchPolicyArgs{
    	EnvironmentName: pulumi.String("string"),
    	Repository:      pulumi.String("string"),
    	Name:            pulumi.String("string"),
    })
    
    var repositoryDeploymentBranchPolicyResource = new RepositoryDeploymentBranchPolicy("repositoryDeploymentBranchPolicyResource", RepositoryDeploymentBranchPolicyArgs.builder()
        .environmentName("string")
        .repository("string")
        .name("string")
        .build());
    
    repository_deployment_branch_policy_resource = github.RepositoryDeploymentBranchPolicy("repositoryDeploymentBranchPolicyResource",
        environment_name="string",
        repository="string",
        name="string")
    
    const repositoryDeploymentBranchPolicyResource = new github.RepositoryDeploymentBranchPolicy("repositoryDeploymentBranchPolicyResource", {
        environmentName: "string",
        repository: "string",
        name: "string",
    });
    
    type: github:RepositoryDeploymentBranchPolicy
    properties:
        environmentName: string
        name: string
        repository: string
    

    RepositoryDeploymentBranchPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The RepositoryDeploymentBranchPolicy resource accepts the following input properties:

    EnvironmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    Repository string
    The repository to create the policy in.
    Name string
    The name pattern that branches must match in order to deploy to the environment.
    EnvironmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    Repository string
    The repository to create the policy in.
    Name string
    The name pattern that branches must match in order to deploy to the environment.
    environmentName String
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    repository String
    The repository to create the policy in.
    name String
    The name pattern that branches must match in order to deploy to the environment.
    environmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    repository string
    The repository to create the policy in.
    name string
    The name pattern that branches must match in order to deploy to the environment.
    environment_name str
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    repository str
    The repository to create the policy in.
    name str
    The name pattern that branches must match in order to deploy to the environment.
    environmentName String
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    repository String
    The repository to create the policy in.
    name String
    The name pattern that branches must match in order to deploy to the environment.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RepositoryDeploymentBranchPolicy resource produces the following output properties:

    Etag string
    An etag representing the Branch object.
    Id string
    The provider-assigned unique ID for this managed resource.
    Etag string
    An etag representing the Branch object.
    Id string
    The provider-assigned unique ID for this managed resource.
    etag String
    An etag representing the Branch object.
    id String
    The provider-assigned unique ID for this managed resource.
    etag string
    An etag representing the Branch object.
    id string
    The provider-assigned unique ID for this managed resource.
    etag str
    An etag representing the Branch object.
    id str
    The provider-assigned unique ID for this managed resource.
    etag String
    An etag representing the Branch object.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing RepositoryDeploymentBranchPolicy Resource

    Get an existing RepositoryDeploymentBranchPolicy 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?: RepositoryDeploymentBranchPolicyState, opts?: CustomResourceOptions): RepositoryDeploymentBranchPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            environment_name: Optional[str] = None,
            etag: Optional[str] = None,
            name: Optional[str] = None,
            repository: Optional[str] = None) -> RepositoryDeploymentBranchPolicy
    func GetRepositoryDeploymentBranchPolicy(ctx *Context, name string, id IDInput, state *RepositoryDeploymentBranchPolicyState, opts ...ResourceOption) (*RepositoryDeploymentBranchPolicy, error)
    public static RepositoryDeploymentBranchPolicy Get(string name, Input<string> id, RepositoryDeploymentBranchPolicyState? state, CustomResourceOptions? opts = null)
    public static RepositoryDeploymentBranchPolicy get(String name, Output<String> id, RepositoryDeploymentBranchPolicyState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    The following state arguments are supported:
    EnvironmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    Etag string
    An etag representing the Branch object.
    Name string
    The name pattern that branches must match in order to deploy to the environment.
    Repository string
    The repository to create the policy in.
    EnvironmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    Etag string
    An etag representing the Branch object.
    Name string
    The name pattern that branches must match in order to deploy to the environment.
    Repository string
    The repository to create the policy in.
    environmentName String
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    etag String
    An etag representing the Branch object.
    name String
    The name pattern that branches must match in order to deploy to the environment.
    repository String
    The repository to create the policy in.
    environmentName string
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    etag string
    An etag representing the Branch object.
    name string
    The name pattern that branches must match in order to deploy to the environment.
    repository string
    The repository to create the policy in.
    environment_name str
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    etag str
    An etag representing the Branch object.
    name str
    The name pattern that branches must match in order to deploy to the environment.
    repository str
    The repository to create the policy in.
    environmentName String
    The name of the environment. This environment must have deployment_branch_policy.custom_branch_policies set to true or a 404 error will be thrown.
    etag String
    An etag representing the Branch object.
    name String
    The name pattern that branches must match in order to deploy to the environment.
    repository String
    The repository to create the policy in.

    Import

    $ pulumi import github:index/repositoryDeploymentBranchPolicy:RepositoryDeploymentBranchPolicy foo repo:env:id
    

    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 github Terraform Provider.
    github logo
    GitHub v6.2.2 published on Tuesday, Jun 18, 2024 by Pulumi