layout | page_title | description |
---|---|---|
github |
GitHub: github_repository |
Creates and manages repositories within GitHub organizations or personal accounts |
This resource allows you to create and manage repositories within your GitHub organization or personal account.
resource "github_repository" "example" {
name = "example"
description = "My awesome codebase"
visibility = "public"
template {
owner = "github"
repository = "terraform-module-template"
}
}
The following arguments are supported:
-
name
- (Required) The name of the repository. -
description
- (Optional) A description of the repository. -
homepage_url
- (Optional) URL of a page describing the project. -
private
- (Optional) Set totrue
to create a private repository. Repositories are created as public (e.g. open source) by default. -
visibility
- (Optional) Can bepublic
orprivate
. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, visibility can also beinternal
. Thevisibility
parameter overrides theprivate
parameter. -
has_issues
- (Optional) Set totrue
to enable the GitHub Issues features on the repository. -
has_projects
- (Optional) Set totrue
to enable the GitHub Projects features on the repository. Per the GitHub documentation when in an organization that has disabled repository projects it will default tofalse
and will otherwise default totrue
. If you specifytrue
when it has been disabled it will return an error. -
has_wiki
- (Optional) Set totrue
to enable the GitHub Wiki features on the repository. -
is_template
- (Optional) Set totrue
to tell GitHub that this is a template repository. -
allow_merge_commit
- (Optional) Set tofalse
to disable merge commits on the repository. -
allow_squash_merge
- (Optional) Set tofalse
to disable squash merges on the repository. -
allow_rebase_merge
- (Optional) Set tofalse
to disable rebase merges on the repository. -
delete_branch_on_merge
- (Optional) Automatically delete head branch after a pull request is merged. Defaults tofalse
. -
has_downloads
- (Optional) Set totrue
to enable the (deprecated) downloads features on the repository. -
auto_init
- (Optional) Set totrue
to produce an initial commit in the repository. -
gitignore_template
- (Optional) Use the name of the template without the extension. For example, "Haskell". -
license_template
- (Optional) Use the name of the template without the extension. For example, "mit" or "mpl-2.0". -
default_branch
- (Optional) (Deprecated: Usegithub_branch_default
resource instead) The name of the default branch of the repository. NOTE: This can only be set after a repository has already been created, and after a correct reference has been created for the target branch inside the repository. This means a user will have to omit this parameter from the initial repository creation and create the target branch inside of the repository prior to setting this attribute. -
archived
- (Optional) Specifies if the repository should be archived. Defaults tofalse
. NOTE Currently, the API does not support unarchiving. -
archive_on_destroy
- (Optional) Set totrue
to archive the repository instead of deleting on destroy. -
topics
- (Optional) The list of topics of the repository. -
template
- (Optional) Use a template repository to create this resource. See Template Repositories below for details. -
vulnerability_alerts
(Optional) - Set totrue
to enable security alerts for vulnerable dependencies. Enabling requires alerts to be enabled on the owner level. (Note for importing: GitHub enables the alerts on public repos but disables them on private repos by default.) See GitHub Documentation for details.
template
supports the following arguments:
owner
: The GitHub organization or user the template repository is owned by.repository
: The name of the template repository.
The following additional attributes are exported:
-
node_id
- the Node ID of the Repository. -
full_name
- A string of the form "orgname/reponame". -
html_url
- URL to the repository on the web. -
ssh_clone_url
- URL that can be provided togit clone
to clone the repository via SSH. -
http_clone_url
- URL that can be provided togit clone
to clone the repository via HTTPS. -
git_clone_url
- URL that can be provided togit clone
to clone the repository anonymously via the git protocol. -
svn_url
- URL that can be provided tosvn checkout
to check out the repository via GitHub's Subversion protocol emulation. -
node_id
- GraphQL global node id for use with v4 API -
repo_id
- Github ID for the repository
Repositories can be imported using the name
, e.g.
$ terraform import github_repository.terraform terraform