1. Packages
  2. GitHub
  3. API Docs
  4. RepositoryFile
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

github.RepositoryFile

Explore with Pulumi AI

github logo
GitHub v6.1.0 published on Monday, Mar 11, 2024 by Pulumi

    This resource allows you to create and manage files within a GitHub repository.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as github from "@pulumi/github";
    
    const fooRepository = new github.Repository("fooRepository", {autoInit: true});
    const fooRepositoryFile = new github.RepositoryFile("fooRepositoryFile", {
        repository: fooRepository.name,
        branch: "main",
        file: ".gitignore",
        content: "**/*.tfstate",
        commitMessage: "Managed by Terraform",
        commitAuthor: "Terraform User",
        commitEmail: "terraform@example.com",
        overwriteOnCreate: true,
    });
    
    import pulumi
    import pulumi_github as github
    
    foo_repository = github.Repository("fooRepository", auto_init=True)
    foo_repository_file = github.RepositoryFile("fooRepositoryFile",
        repository=foo_repository.name,
        branch="main",
        file=".gitignore",
        content="**/*.tfstate",
        commit_message="Managed by Terraform",
        commit_author="Terraform User",
        commit_email="terraform@example.com",
        overwrite_on_create=True)
    
    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 {
    		fooRepository, err := github.NewRepository(ctx, "fooRepository", &github.RepositoryArgs{
    			AutoInit: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = github.NewRepositoryFile(ctx, "fooRepositoryFile", &github.RepositoryFileArgs{
    			Repository:        fooRepository.Name,
    			Branch:            pulumi.String("main"),
    			File:              pulumi.String(".gitignore"),
    			Content:           pulumi.String("**/*.tfstate"),
    			CommitMessage:     pulumi.String("Managed by Terraform"),
    			CommitAuthor:      pulumi.String("Terraform User"),
    			CommitEmail:       pulumi.String("terraform@example.com"),
    			OverwriteOnCreate: pulumi.Bool(true),
    		})
    		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 fooRepository = new Github.Repository("fooRepository", new()
        {
            AutoInit = true,
        });
    
        var fooRepositoryFile = new Github.RepositoryFile("fooRepositoryFile", new()
        {
            Repository = fooRepository.Name,
            Branch = "main",
            File = ".gitignore",
            Content = "**/*.tfstate",
            CommitMessage = "Managed by Terraform",
            CommitAuthor = "Terraform User",
            CommitEmail = "terraform@example.com",
            OverwriteOnCreate = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.github.Repository;
    import com.pulumi.github.RepositoryArgs;
    import com.pulumi.github.RepositoryFile;
    import com.pulumi.github.RepositoryFileArgs;
    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 fooRepository = new Repository("fooRepository", RepositoryArgs.builder()        
                .autoInit(true)
                .build());
    
            var fooRepositoryFile = new RepositoryFile("fooRepositoryFile", RepositoryFileArgs.builder()        
                .repository(fooRepository.name())
                .branch("main")
                .file(".gitignore")
                .content("**/*.tfstate")
                .commitMessage("Managed by Terraform")
                .commitAuthor("Terraform User")
                .commitEmail("terraform@example.com")
                .overwriteOnCreate(true)
                .build());
    
        }
    }
    
    resources:
      fooRepository:
        type: github:Repository
        properties:
          autoInit: true
      fooRepositoryFile:
        type: github:RepositoryFile
        properties:
          repository: ${fooRepository.name}
          branch: main
          file: .gitignore
          content: '**/*.tfstate'
          commitMessage: Managed by Terraform
          commitAuthor: Terraform User
          commitEmail: terraform@example.com
          overwriteOnCreate: true
    

    Create RepositoryFile Resource

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

    Constructor syntax

    new RepositoryFile(name: string, args: RepositoryFileArgs, opts?: CustomResourceOptions);
    @overload
    def RepositoryFile(resource_name: str,
                       args: RepositoryFileArgs,
                       opts: Optional[ResourceOptions] = None)
    
    @overload
    def RepositoryFile(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       content: Optional[str] = None,
                       file: Optional[str] = None,
                       repository: Optional[str] = None,
                       branch: Optional[str] = None,
                       commit_author: Optional[str] = None,
                       commit_email: Optional[str] = None,
                       commit_message: Optional[str] = None,
                       overwrite_on_create: Optional[bool] = None)
    func NewRepositoryFile(ctx *Context, name string, args RepositoryFileArgs, opts ...ResourceOption) (*RepositoryFile, error)
    public RepositoryFile(string name, RepositoryFileArgs args, CustomResourceOptions? opts = null)
    public RepositoryFile(String name, RepositoryFileArgs args)
    public RepositoryFile(String name, RepositoryFileArgs args, CustomResourceOptions options)
    
    type: github:RepositoryFile
    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 RepositoryFileArgs
    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 RepositoryFileArgs
    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 RepositoryFileArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RepositoryFileArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RepositoryFileArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var repositoryFileResource = new Github.RepositoryFile("repositoryFileResource", new()
    {
        Content = "string",
        File = "string",
        Repository = "string",
        Branch = "string",
        CommitAuthor = "string",
        CommitEmail = "string",
        CommitMessage = "string",
        OverwriteOnCreate = false,
    });
    
    example, err := github.NewRepositoryFile(ctx, "repositoryFileResource", &github.RepositoryFileArgs{
    	Content:           pulumi.String("string"),
    	File:              pulumi.String("string"),
    	Repository:        pulumi.String("string"),
    	Branch:            pulumi.String("string"),
    	CommitAuthor:      pulumi.String("string"),
    	CommitEmail:       pulumi.String("string"),
    	CommitMessage:     pulumi.String("string"),
    	OverwriteOnCreate: pulumi.Bool(false),
    })
    
    var repositoryFileResource = new RepositoryFile("repositoryFileResource", RepositoryFileArgs.builder()        
        .content("string")
        .file("string")
        .repository("string")
        .branch("string")
        .commitAuthor("string")
        .commitEmail("string")
        .commitMessage("string")
        .overwriteOnCreate(false)
        .build());
    
    repository_file_resource = github.RepositoryFile("repositoryFileResource",
        content="string",
        file="string",
        repository="string",
        branch="string",
        commit_author="string",
        commit_email="string",
        commit_message="string",
        overwrite_on_create=False)
    
    const repositoryFileResource = new github.RepositoryFile("repositoryFileResource", {
        content: "string",
        file: "string",
        repository: "string",
        branch: "string",
        commitAuthor: "string",
        commitEmail: "string",
        commitMessage: "string",
        overwriteOnCreate: false,
    });
    
    type: github:RepositoryFile
    properties:
        branch: string
        commitAuthor: string
        commitEmail: string
        commitMessage: string
        content: string
        file: string
        overwriteOnCreate: false
        repository: string
    

    RepositoryFile 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 RepositoryFile resource accepts the following input properties:

    Content string
    The file content.
    File string
    The path of the file to manage.
    Repository string
    The repository to create the file in.
    Branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    CommitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    CommitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    CommitMessage string
    The commit message when creating, updating or deleting the managed file.
    OverwriteOnCreate bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    Content string
    The file content.
    File string
    The path of the file to manage.
    Repository string
    The repository to create the file in.
    Branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    CommitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    CommitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    CommitMessage string
    The commit message when creating, updating or deleting the managed file.
    OverwriteOnCreate bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    content String
    The file content.
    file String
    The path of the file to manage.
    repository String
    The repository to create the file in.
    branch String
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor String
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail String
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage String
    The commit message when creating, updating or deleting the managed file.
    overwriteOnCreate Boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    content string
    The file content.
    file string
    The path of the file to manage.
    repository string
    The repository to create the file in.
    branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage string
    The commit message when creating, updating or deleting the managed file.
    overwriteOnCreate boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    content str
    The file content.
    file str
    The path of the file to manage.
    repository str
    The repository to create the file in.
    branch str
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commit_author str
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commit_email str
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commit_message str
    The commit message when creating, updating or deleting the managed file.
    overwrite_on_create bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    content String
    The file content.
    file String
    The path of the file to manage.
    repository String
    The repository to create the file in.
    branch String
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor String
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail String
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage String
    The commit message when creating, updating or deleting the managed file.
    overwriteOnCreate Boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.

    Outputs

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

    CommitSha string
    The SHA of the commit that modified the file.
    Id string
    The provider-assigned unique ID for this managed resource.
    Ref string
    The name of the commit/branch/tag.
    Sha string
    The SHA blob of the file.
    CommitSha string
    The SHA of the commit that modified the file.
    Id string
    The provider-assigned unique ID for this managed resource.
    Ref string
    The name of the commit/branch/tag.
    Sha string
    The SHA blob of the file.
    commitSha String
    The SHA of the commit that modified the file.
    id String
    The provider-assigned unique ID for this managed resource.
    ref String
    The name of the commit/branch/tag.
    sha String
    The SHA blob of the file.
    commitSha string
    The SHA of the commit that modified the file.
    id string
    The provider-assigned unique ID for this managed resource.
    ref string
    The name of the commit/branch/tag.
    sha string
    The SHA blob of the file.
    commit_sha str
    The SHA of the commit that modified the file.
    id str
    The provider-assigned unique ID for this managed resource.
    ref str
    The name of the commit/branch/tag.
    sha str
    The SHA blob of the file.
    commitSha String
    The SHA of the commit that modified the file.
    id String
    The provider-assigned unique ID for this managed resource.
    ref String
    The name of the commit/branch/tag.
    sha String
    The SHA blob of the file.

    Look up Existing RepositoryFile Resource

    Get an existing RepositoryFile 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?: RepositoryFileState, opts?: CustomResourceOptions): RepositoryFile
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            branch: Optional[str] = None,
            commit_author: Optional[str] = None,
            commit_email: Optional[str] = None,
            commit_message: Optional[str] = None,
            commit_sha: Optional[str] = None,
            content: Optional[str] = None,
            file: Optional[str] = None,
            overwrite_on_create: Optional[bool] = None,
            ref: Optional[str] = None,
            repository: Optional[str] = None,
            sha: Optional[str] = None) -> RepositoryFile
    func GetRepositoryFile(ctx *Context, name string, id IDInput, state *RepositoryFileState, opts ...ResourceOption) (*RepositoryFile, error)
    public static RepositoryFile Get(string name, Input<string> id, RepositoryFileState? state, CustomResourceOptions? opts = null)
    public static RepositoryFile get(String name, Output<String> id, RepositoryFileState 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:
    Branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    CommitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    CommitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    CommitMessage string
    The commit message when creating, updating or deleting the managed file.
    CommitSha string
    The SHA of the commit that modified the file.
    Content string
    The file content.
    File string
    The path of the file to manage.
    OverwriteOnCreate bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    Ref string
    The name of the commit/branch/tag.
    Repository string
    The repository to create the file in.
    Sha string
    The SHA blob of the file.
    Branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    CommitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    CommitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    CommitMessage string
    The commit message when creating, updating or deleting the managed file.
    CommitSha string
    The SHA of the commit that modified the file.
    Content string
    The file content.
    File string
    The path of the file to manage.
    OverwriteOnCreate bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    Ref string
    The name of the commit/branch/tag.
    Repository string
    The repository to create the file in.
    Sha string
    The SHA blob of the file.
    branch String
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor String
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail String
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage String
    The commit message when creating, updating or deleting the managed file.
    commitSha String
    The SHA of the commit that modified the file.
    content String
    The file content.
    file String
    The path of the file to manage.
    overwriteOnCreate Boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    ref String
    The name of the commit/branch/tag.
    repository String
    The repository to create the file in.
    sha String
    The SHA blob of the file.
    branch string
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor string
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail string
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage string
    The commit message when creating, updating or deleting the managed file.
    commitSha string
    The SHA of the commit that modified the file.
    content string
    The file content.
    file string
    The path of the file to manage.
    overwriteOnCreate boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    ref string
    The name of the commit/branch/tag.
    repository string
    The repository to create the file in.
    sha string
    The SHA blob of the file.
    branch str
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commit_author str
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commit_email str
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commit_message str
    The commit message when creating, updating or deleting the managed file.
    commit_sha str
    The SHA of the commit that modified the file.
    content str
    The file content.
    file str
    The path of the file to manage.
    overwrite_on_create bool
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    ref str
    The name of the commit/branch/tag.
    repository str
    The repository to create the file in.
    sha str
    The SHA blob of the file.
    branch String
    Git branch (defaults to the repository's default branch). The branch must already exist, it will not be created if it does not already exist.
    commitAuthor String
    Committer author name to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This maybe useful when a branch protection rule requires signed commits.
    commitEmail String
    Committer email address to use. NOTE: GitHub app users may omit author and email information so GitHub can verify commits as the GitHub App. This may be useful when a branch protection rule requires signed commits.
    commitMessage String
    The commit message when creating, updating or deleting the managed file.
    commitSha String
    The SHA of the commit that modified the file.
    content String
    The file content.
    file String
    The path of the file to manage.
    overwriteOnCreate Boolean
    Enable overwriting existing files. If set to true it will overwrite an existing file with the same name. If set to false it will fail if there is an existing file with the same name.
    ref String
    The name of the commit/branch/tag.
    repository String
    The repository to create the file in.
    sha String
    The SHA blob of the file.

    Import

    Repository files can be imported using a combination of the repo and file, e.g.

    $ pulumi import github:index/repositoryFile:RepositoryFile gitignore example/.gitignore
    

    To import a file from a branch other than the default branch, append : and the branch name, e.g.

    $ pulumi import github:index/repositoryFile:RepositoryFile gitignore example/.gitignore:dev
    

    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.1.0 published on Monday, Mar 11, 2024 by Pulumi