github.RepositoryFile
Explore with Pulumi AI
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 foo = new github.Repository("foo", {
name: "tf-acc-test-%s",
autoInit: true,
});
const fooRepositoryFile = new github.RepositoryFile("foo", {
repository: foo.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 = github.Repository("foo",
name="tf-acc-test-%s",
auto_init=True)
foo_repository_file = github.RepositoryFile("foo",
repository=foo.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 {
foo, err := github.NewRepository(ctx, "foo", &github.RepositoryArgs{
Name: pulumi.String("tf-acc-test-%s"),
AutoInit: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = github.NewRepositoryFile(ctx, "foo", &github.RepositoryFileArgs{
Repository: foo.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 foo = new Github.Repository("foo", new()
{
Name = "tf-acc-test-%s",
AutoInit = true,
});
var fooRepositoryFile = new Github.RepositoryFile("foo", new()
{
Repository = foo.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 foo = new Repository("foo", RepositoryArgs.builder()
.name("tf-acc-test-%s")
.autoInit(true)
.build());
var fooRepositoryFile = new RepositoryFile("fooRepositoryFile", RepositoryFileArgs.builder()
.repository(foo.name())
.branch("main")
.file(".gitignore")
.content("**/*.tfstate")
.commitMessage("Managed by Terraform")
.commitAuthor("Terraform User")
.commitEmail("terraform@example.com")
.overwriteOnCreate(true)
.build());
}
}
resources:
foo:
type: github:Repository
properties:
name: tf-acc-test-%s
autoInit: true
fooRepositoryFile:
type: github:RepositoryFile
name: foo
properties:
repository: ${foo.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.
Constructor 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.
- 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.
- Commit
Email 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.
- Commit
Message string - The commit message when creating, updating or deleting the managed file.
- Overwrite
On boolCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- Commit
Email 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.
- Commit
Message string - The commit message when creating, updating or deleting the managed file.
- Overwrite
On boolCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message String - The commit message when creating, updating or deleting the managed file.
- overwrite
On BooleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message string - The commit message when creating, updating or deleting the managed file.
- overwrite
On booleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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_ boolcreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message String - The commit message when creating, updating or deleting the managed file.
- overwrite
On BooleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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:
- 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.
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.
- 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.
- 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.
- Commit
Email 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.
- Commit
Message string - The commit message when creating, updating or deleting the managed file.
- Commit
Sha string - The SHA of the commit that modified the file.
- Content string
- The file content.
- File string
- The path of the file to manage.
- Overwrite
On boolCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- Commit
Email 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.
- Commit
Message string - The commit message when creating, updating or deleting the managed file.
- Commit
Sha string - The SHA of the commit that modified the file.
- Content string
- The file content.
- File string
- The path of the file to manage.
- Overwrite
On boolCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message String - The commit message when creating, updating or deleting the managed file.
- commit
Sha String - The SHA of the commit that modified the file.
- content String
- The file content.
- file String
- The path of the file to manage.
- overwrite
On BooleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message string - The commit message when creating, updating or deleting the managed file.
- commit
Sha string - The SHA of the commit that modified the file.
- content string
- The file content.
- file string
- The path of the file to manage.
- overwrite
On booleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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_ boolcreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.
- 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.
- commit
Email 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.
- commit
Message String - The commit message when creating, updating or deleting the managed file.
- commit
Sha String - The SHA of the commit that modified the file.
- content String
- The file content.
- file String
- The path of the file to manage.
- overwrite
On BooleanCreate - Enable overwriting existing files. If set to
true
it will overwrite an existing file with the same name. If set tofalse
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.