Repository Environment Args
data class RepositoryEnvironmentArgs(val canAdminsBypass: Output<Boolean>? = null, val deploymentBranchPolicy: Output<RepositoryEnvironmentDeploymentBranchPolicyArgs>? = null, val environment: Output<String>? = null, val preventSelfReview: Output<Boolean>? = null, val repository: Output<String>? = null, val reviewers: Output<List<RepositoryEnvironmentReviewerArgs>>? = null, val waitTimer: Output<Int>? = null) : ConvertibleToJava<RepositoryEnvironmentArgs>
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,
},
});
Content copied to clipboard
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,
})
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 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,
},
});
});
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
}
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
})
}
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 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());
}
}
Content copied to clipboard
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: ""
Content copied to clipboard
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
Content copied to clipboard
Constructors
Link copied to clipboard
constructor(canAdminsBypass: Output<Boolean>? = null, deploymentBranchPolicy: Output<RepositoryEnvironmentDeploymentBranchPolicyArgs>? = null, environment: Output<String>? = null, preventSelfReview: Output<Boolean>? = null, repository: Output<String>? = null, reviewers: Output<List<RepositoryEnvironmentReviewerArgs>>? = null, waitTimer: Output<Int>? = null)
Properties
Link copied to clipboard
Can repository admins bypass the environment protections. Defaults to true
.
Link copied to clipboard
The deployment branch policy configuration
Link copied to clipboard
The name of the environment.
Link copied to clipboard
Whether or not a user who created the job is prevented from approving their own job. Defaults to false
.
Link copied to clipboard
The repository of the environment.
Link copied to clipboard
The environment reviewers configuration.