Skip to content

A Terraform provider for managing files in GitHub repositories.

License

Notifications You must be signed in to change notification settings

form3tech-oss/terraform-provider-githubfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-provider-githubfile

Build status

A Terraform provider for managing files in GitHub repositories.

Use-cases

A few possible use-cases for terraform-provider-githubfile are:

  • Adding a LICENSE file to a number of repositories.
  • Making sure repositories across an organisation have consistent issue/pull request templates.
  • Configuring a tool such as golangci-lint or pre-commit uniformly across a number of repositories

Installation

Download the relevant binary from releases and copy it to $HOME/.terraform.d/plugins/.

Configuration

The following provider block variables are available for configuration:

Name Description
commit_message_prefix An optional prefix to be added to all commits generated as a result of manipulating files.
github_email The email address to use for commit messages.
If a GPG key is provided, this must match the one which the key corresponds to.
github_token A GitHub authorisation token with repo permissions and having admin access to the target repositories.
github_username The username to use for commit messages.
gpg_passphrase The passphrase associated with the provided gpg_secret_key (see below).
gpg_secret_key The GPG secret key to be use for commit signing.
If left empty, commits will not be signed.

Alternatively, these values can be read from environment variables.

Resources

githubfile_file

The githubfile_file resource represents a file in a given branch of a GitHub repository.

Attributes

Name Description
repository_owner The owner of the repository.
repository_name The name of the repository.
branch The branch in which to create/update the file
Leaving this empty will cause the file to be created/updated in the default branch.
path The path to the file being created/updated.
contents The contents of the file.

Example

resource "githubfile_file" "form3tech_oss_terraform_provider_githubfile_issue_template" {
    repository_owner            = "form3tech-oss"
    repository_name             = "terraform-provider-githubfile"
    branch                      = ""
    path                        = ".github/ISSUE_TEMPLATE.md"
    contents                    = <<EOF
# Issue Type

- [ ] Bug report.
- [ ] Suggestion.

# Description

<!-- Please provide a description of the issue. -->
EOF
}

Creating the resource above will result in the .github/ISSUE_TEMPLATE.md file being created/updated on the default branch of the form3tech-oss/terraform-provider-githubfile repository with the following contents:

# Issue Type

- [ ] Bug report.
- [ ] Suggestion.

# Description

<!-- Please provide a description of the issue. -->