Repository Environment Deployment Policy Args
data class RepositoryEnvironmentDeploymentPolicyArgs(val branchPattern: Output<String>? = null, val environment: Output<String>? = null, val repository: Output<String>? = null, val tagPattern: Output<String>? = null) : ConvertibleToJava<RepositoryEnvironmentDeploymentPolicyArgs>
This resource allows you to create and manage environment deployment branch policies for a GitHub repository.
Example Usage
Create a branch-based deployment policy:
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/*",
});
Content copied to clipboard
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/*")
Content copied to clipboard
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/*",
});
});
Content copied to clipboard
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
})
}
Content copied to clipboard
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.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());
}
}
Content copied to clipboard
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: ""
Content copied to clipboard
Create a tag-based deployment policy:
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,
tagPattern: "v*",
});
Content copied to clipboard
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,
tag_pattern="v*")
Content copied to clipboard
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,
TagPattern = "v*",
});
});
Content copied to clipboard
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,
TagPattern: pulumi.String("v*"),
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
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.id())
.build())
.deploymentBranchPolicy(RepositoryEnvironmentDeploymentBranchPolicyArgs.builder()
.protectedBranches(false)
.customBranchPolicies(true)
.build())
.build());
var testRepositoryEnvironmentDeploymentPolicy = new RepositoryEnvironmentDeploymentPolicy("testRepositoryEnvironmentDeploymentPolicy", RepositoryEnvironmentDeploymentPolicyArgs.builder()
.repository(test.name())
.environment(testRepositoryEnvironment.environment())
.tagPattern("v*")
.build());
}
}
Content copied to clipboard
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}
tagPattern: v*
variables:
current:
fn::invoke:
function: github:getUser
arguments:
username: ""
Content copied to clipboard
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
Content copied to clipboard
Properties
Link copied to clipboard
The name pattern that branches must match in order to deploy to the environment. If not specified, tag_pattern
must be specified.
Link copied to clipboard
The name of the environment.
Link copied to clipboard
The repository of the environment.
Link copied to clipboard
The name pattern that tags must match in order to deploy to the environment. If not specified, branch_pattern
must be specified. //////