This Terraform code automates the creation of a new GitHub repository, adds a file to it, and creates a new branch within it. The code is written in HashiCorp Configuration Language (HCL) and uses Terraform to manage the resources.
This resource creates a new GitHub repository with the name, description, and visibility specified in the var.repository_details variable.
name: The name of the new GitHub repository, taken from thevar.repository_details.namevariable.description: The description of the new GitHub repository, taken from thevar.repository_details.descriptionvariable.auto_init: Whether to initialize the repository with a README.md file or not, taken from thevar.repository_details.auto_initvariable.visibility: The visibility of the new GitHub repository, which can be "public", "private", or "internal", taken from thevar.repository_details.visibilityvariable.
This resource creates a new file within the GitHub repository created by the previous resource.
repository: The name of the GitHub repository to add the file to, taken from thegithub_repository.new-repo.nameoutput of the previous resource.branch: The name of the branch to create or update the file in, taken from thevar.repository_file_details.branchvariable.file: The path of the file to create or update within the branch, taken from thevar.repository_file_details.filevariable.content: The content of the file to create or update, taken from thevar.repository_file_details.contentvariable.commit_message: The commit message to use when committing the file changes, taken from thevar.repository_file_details.commit_messagevariable.commit_author: The name of the commit author, taken from thevar.repository_file_details.commit_authorvariable.commit_email: The email of the commit author, taken from thevar.repository_file_details.commit_emailvariable.overwrite_on_create: Whether to overwrite the file if it already exists or not, taken from thevar.repository_file_details.overwrite_on_createvariable.
This resource creates a new branch within the GitHub repository created by the first resource.
repository: The name of the GitHub repository to create the branch in, taken from thegithub_repository.new-repo.nameoutput of the first resource.branch: The name of the new branch, taken from thevar.gitbranch_detailsvariable.
run these commands:
$ terraform init
$ terraform validate
$ terraform fmt
$ terraform plan
$ terraform apply
for delete:
$ terraform destroy
