RepositoryEnvironment

class RepositoryEnvironment : KotlinCustomResource

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,
})
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 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
})
}
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.applyValue(getUserResult -> getUserResult.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: ""

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

Properties

Link copied to clipboard
val canAdminsBypass: Output<Boolean>?

Can repository admins bypass the environment protections. Defaults to true.

Link copied to clipboard

The deployment branch policy configuration

Link copied to clipboard
val environment: Output<String>

The name of the environment.

Link copied to clipboard
val id: Output<String>
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
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val repository: Output<String>

The repository of the environment.

Link copied to clipboard

The environment reviewers configuration.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val waitTimer: Output<Int>?

Amount of time to delay a job after the job is initially triggered.