github.RepositoryEnvironmentDeploymentPolicy
Explore with Pulumi AI
This resource allows you to create and manage environment deployment branch policies for a GitHub repository.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const current = github.getUser({
username: "",
});
const test = new github.Repository("test", {name: "tf-acc-test-%s"});
const testRepositoryEnvironment = new github.RepositoryEnvironment("test", {
repository: test.name,
environment: "environment/test",
waitTimer: 10000,
reviewers: [{
users: [current.then(current => current.id)],
}],
deploymentBranchPolicy: {
protectedBranches: false,
customBranchPolicies: true,
},
});
const testRepositoryEnvironmentDeploymentPolicy = new github.RepositoryEnvironmentDeploymentPolicy("test", {
repository: test.name,
environment: testRepositoryEnvironment.environment,
branchPattern: "releases/*",
});
import pulumi
import pulumi_github as github
current = github.get_user(username="")
test = github.Repository("test", name="tf-acc-test-%s")
test_repository_environment = github.RepositoryEnvironment("test",
repository=test.name,
environment="environment/test",
wait_timer=10000,
reviewers=[{
"users": [current.id],
}],
deployment_branch_policy={
"protected_branches": False,
"custom_branch_policies": True,
})
test_repository_environment_deployment_policy = github.RepositoryEnvironmentDeploymentPolicy("test",
repository=test.name,
environment=test_repository_environment.environment,
branch_pattern="releases/*")
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
}
test, err := github.NewRepository(ctx, "test", &github.RepositoryArgs{
Name: pulumi.String("tf-acc-test-%s"),
})
if err != nil {
return err
}
testRepositoryEnvironment, err := github.NewRepositoryEnvironment(ctx, "test", &github.RepositoryEnvironmentArgs{
Repository: test.Name,
Environment: pulumi.String("environment/test"),
WaitTimer: pulumi.Int(10000),
Reviewers: github.RepositoryEnvironmentReviewerArray{
&github.RepositoryEnvironmentReviewerArgs{
Users: pulumi.IntArray{
pulumi.String(current.Id),
},
},
},
DeploymentBranchPolicy: &github.RepositoryEnvironmentDeploymentBranchPolicyArgs{
ProtectedBranches: pulumi.Bool(false),
CustomBranchPolicies: pulumi.Bool(true),
},
})
if err != nil {
return err
}
_, err = github.NewRepositoryEnvironmentDeploymentPolicy(ctx, "test", &github.RepositoryEnvironmentDeploymentPolicyArgs{
Repository: test.Name,
Environment: testRepositoryEnvironment.Environment,
BranchPattern: pulumi.String("releases/*"),
})
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 test = new Github.Repository("test", new()
{
Name = "tf-acc-test-%s",
});
var testRepositoryEnvironment = new Github.RepositoryEnvironment("test", new()
{
Repository = test.Name,
Environment = "environment/test",
WaitTimer = 10000,
Reviewers = new[]
{
new Github.Inputs.RepositoryEnvironmentReviewerArgs
{
Users = new[]
{
current.Apply(getUserResult => getUserResult.Id),
},
},
},
DeploymentBranchPolicy = new Github.Inputs.RepositoryEnvironmentDeploymentBranchPolicyArgs
{
ProtectedBranches = false,
CustomBranchPolicies = true,
},
});
var testRepositoryEnvironmentDeploymentPolicy = new Github.RepositoryEnvironmentDeploymentPolicy("test", new()
{
Repository = test.Name,
Environment = testRepositoryEnvironment.Environment,
BranchPattern = "releases/*",
});
});
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 com.pulumi.github.RepositoryEnvironmentDeploymentPolicy;
import com.pulumi.github.RepositoryEnvironmentDeploymentPolicyArgs;
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 test = new Repository("test", RepositoryArgs.builder()
.name("tf-acc-test-%s")
.build());
var testRepositoryEnvironment = new RepositoryEnvironment("testRepositoryEnvironment", RepositoryEnvironmentArgs.builder()
.repository(test.name())
.environment("environment/test")
.waitTimer(10000)
.reviewers(RepositoryEnvironmentReviewerArgs.builder()
.users(current.applyValue(getUserResult -> getUserResult.id()))
.build())
.deploymentBranchPolicy(RepositoryEnvironmentDeploymentBranchPolicyArgs.builder()
.protectedBranches(false)
.customBranchPolicies(true)
.build())
.build());
var testRepositoryEnvironmentDeploymentPolicy = new RepositoryEnvironmentDeploymentPolicy("testRepositoryEnvironmentDeploymentPolicy", RepositoryEnvironmentDeploymentPolicyArgs.builder()
.repository(test.name())
.environment(testRepositoryEnvironment.environment())
.branchPattern("releases/*")
.build());
}
}
resources:
test:
type: github:Repository
properties:
name: tf-acc-test-%s
testRepositoryEnvironment:
type: github:RepositoryEnvironment
name: test
properties:
repository: ${test.name}
environment: environment/test
waitTimer: 10000
reviewers:
- users:
- ${current.id}
deploymentBranchPolicy:
protectedBranches: false
customBranchPolicies: true
testRepositoryEnvironmentDeploymentPolicy:
type: github:RepositoryEnvironmentDeploymentPolicy
name: test
properties:
repository: ${test.name}
environment: ${testRepositoryEnvironment.environment}
branchPattern: releases/*
variables:
current:
fn::invoke:
Function: github:getUser
Arguments:
username:
Create RepositoryEnvironmentDeploymentPolicy Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RepositoryEnvironmentDeploymentPolicy(name: string, args: RepositoryEnvironmentDeploymentPolicyArgs, opts?: CustomResourceOptions);
@overload
def RepositoryEnvironmentDeploymentPolicy(resource_name: str,
args: RepositoryEnvironmentDeploymentPolicyArgs,
opts: Optional[ResourceOptions] = None)
@overload
def RepositoryEnvironmentDeploymentPolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
branch_pattern: Optional[str] = None,
environment: Optional[str] = None,
repository: Optional[str] = None)
func NewRepositoryEnvironmentDeploymentPolicy(ctx *Context, name string, args RepositoryEnvironmentDeploymentPolicyArgs, opts ...ResourceOption) (*RepositoryEnvironmentDeploymentPolicy, error)
public RepositoryEnvironmentDeploymentPolicy(string name, RepositoryEnvironmentDeploymentPolicyArgs args, CustomResourceOptions? opts = null)
public RepositoryEnvironmentDeploymentPolicy(String name, RepositoryEnvironmentDeploymentPolicyArgs args)
public RepositoryEnvironmentDeploymentPolicy(String name, RepositoryEnvironmentDeploymentPolicyArgs args, CustomResourceOptions options)
type: github:RepositoryEnvironmentDeploymentPolicy
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 RepositoryEnvironmentDeploymentPolicyArgs
- 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 RepositoryEnvironmentDeploymentPolicyArgs
- 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 RepositoryEnvironmentDeploymentPolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RepositoryEnvironmentDeploymentPolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RepositoryEnvironmentDeploymentPolicyArgs
- 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 repositoryEnvironmentDeploymentPolicyResource = new Github.RepositoryEnvironmentDeploymentPolicy("repositoryEnvironmentDeploymentPolicyResource", new()
{
BranchPattern = "string",
Environment = "string",
Repository = "string",
});
example, err := github.NewRepositoryEnvironmentDeploymentPolicy(ctx, "repositoryEnvironmentDeploymentPolicyResource", &github.RepositoryEnvironmentDeploymentPolicyArgs{
BranchPattern: pulumi.String("string"),
Environment: pulumi.String("string"),
Repository: pulumi.String("string"),
})
var repositoryEnvironmentDeploymentPolicyResource = new RepositoryEnvironmentDeploymentPolicy("repositoryEnvironmentDeploymentPolicyResource", RepositoryEnvironmentDeploymentPolicyArgs.builder()
.branchPattern("string")
.environment("string")
.repository("string")
.build());
repository_environment_deployment_policy_resource = github.RepositoryEnvironmentDeploymentPolicy("repositoryEnvironmentDeploymentPolicyResource",
branch_pattern="string",
environment="string",
repository="string")
const repositoryEnvironmentDeploymentPolicyResource = new github.RepositoryEnvironmentDeploymentPolicy("repositoryEnvironmentDeploymentPolicyResource", {
branchPattern: "string",
environment: "string",
repository: "string",
});
type: github:RepositoryEnvironmentDeploymentPolicy
properties:
branchPattern: string
environment: string
repository: string
RepositoryEnvironmentDeploymentPolicy 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 RepositoryEnvironmentDeploymentPolicy resource accepts the following input properties:
- Branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- Branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- branch
Pattern String - The name pattern that branches must match in order to deploy to the environment.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
- branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- environment string
- The name of the environment.
- repository string
- The repository of the environment.
- branch_
pattern str - The name pattern that branches must match in order to deploy to the environment.
- environment str
- The name of the environment.
- repository str
- The repository of the environment.
- branch
Pattern String - The name pattern that branches must match in order to deploy to the environment.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
Outputs
All input properties are implicitly available as output properties. Additionally, the RepositoryEnvironmentDeploymentPolicy 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 RepositoryEnvironmentDeploymentPolicy Resource
Get an existing RepositoryEnvironmentDeploymentPolicy 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?: RepositoryEnvironmentDeploymentPolicyState, opts?: CustomResourceOptions): RepositoryEnvironmentDeploymentPolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
branch_pattern: Optional[str] = None,
environment: Optional[str] = None,
repository: Optional[str] = None) -> RepositoryEnvironmentDeploymentPolicy
func GetRepositoryEnvironmentDeploymentPolicy(ctx *Context, name string, id IDInput, state *RepositoryEnvironmentDeploymentPolicyState, opts ...ResourceOption) (*RepositoryEnvironmentDeploymentPolicy, error)
public static RepositoryEnvironmentDeploymentPolicy Get(string name, Input<string> id, RepositoryEnvironmentDeploymentPolicyState? state, CustomResourceOptions? opts = null)
public static RepositoryEnvironmentDeploymentPolicy get(String name, Output<String> id, RepositoryEnvironmentDeploymentPolicyState 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.
- Branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- Branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- Environment string
- The name of the environment.
- Repository string
- The repository of the environment.
- branch
Pattern String - The name pattern that branches must match in order to deploy to the environment.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
- branch
Pattern string - The name pattern that branches must match in order to deploy to the environment.
- environment string
- The name of the environment.
- repository string
- The repository of the environment.
- branch_
pattern str - The name pattern that branches must match in order to deploy to the environment.
- environment str
- The name of the environment.
- repository str
- The repository of the environment.
- branch
Pattern String - The name pattern that branches must match in order to deploy to the environment.
- environment String
- The name of the environment.
- repository String
- The repository of the environment.
Import
GitHub Repository Environment Deployment Policy can be imported using an ID made up of name
of the repository combined with the environment
name of the environment with the Id
of the deployment policy, separated by a :
character, e.g.
$ pulumi import github:index/repositoryEnvironmentDeploymentPolicy:RepositoryEnvironmentDeploymentPolicy daily terraform:daily:123456
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.