diff --git a/examples/github/README.md b/examples/github/README.md index e69de29..4fd504d 100644 --- a/examples/github/README.md +++ b/examples/github/README.md @@ -0,0 +1,6 @@ +You may export the GitHub token as an environment variable: +``` +export TF_VAR_taken="secret-github-token" +terraform plan +terraform apply +``` \ No newline at end of file diff --git a/examples/github/easy-github-repository-add-new-file/main.tf b/examples/github/easy-github-repository-add-new-file/main.tf new file mode 100644 index 0000000..3957eeb --- /dev/null +++ b/examples/github/easy-github-repository-add-new-file/main.tf @@ -0,0 +1,29 @@ +terraform { + required_version = ">=0.13" + required_providers { + github = { + source = "integrations/github" + version = "~> 6.0" + } + } +} + +provider "github" { + token = var.token +} + +variable "token" { # to be exported as an environment variable + description = "GitHub token for authentication" + type = string +} + +resource "github_repository_file" "my_file" { + repository = github_repository.my_repo.name + branch = "main" + file = "some_file.txt" + content = "some content" + commit_message = "add a file to the repo" + overwrite_on_create = true + autocreate_branch = true +} + diff --git a/examples/github/easy-github-repository-create-new-branch/main.tf b/examples/github/easy-github-repository-create-new-branch/main.tf new file mode 100644 index 0000000..4fc4fa8 --- /dev/null +++ b/examples/github/easy-github-repository-create-new-branch/main.tf @@ -0,0 +1,23 @@ +terraform { + required_version = ">=0.13" + required_providers { + github = { + source = "integrations/github" + version = "~> 6.0" + } + } +} + +provider "github" { + token = var.token +} + +variable "token" { # to be exported as an environment variable + description = "GitHub token for authentication" + type = string +} + +resource "github_branch" "my_branch" { + repository = github_repository.my_repo.name + branch = "dev" +} \ No newline at end of file diff --git a/examples/github/easy-github-repository-create-pull-request/main.tf b/examples/github/easy-github-repository-create-pull-request/main.tf new file mode 100644 index 0000000..f3c010f --- /dev/null +++ b/examples/github/easy-github-repository-create-pull-request/main.tf @@ -0,0 +1,27 @@ +terraform { + required_version = ">=0.13" + required_providers { + github = { + source = "integrations/github" + version = "~> 6.0" + } + } +} + +provider "github" { + token = var.token +} + +variable "token" { # to be exported as an environment variable + description = "GitHub token for authentication" + type = string +} + +resource "github_repository_pullrequest" "my_pullrequest" { + base_repository = "https://github.com/baserepository" + base_ref = "main" + head_repository = github_repository.my_repo.name + head_ref = "feat" + title = "new feature PR" + body = "details about the feature" +} diff --git a/examples/github/easy-github-repository-create-repository/main.tf b/examples/github/easy-github-repository-create-repository/main.tf new file mode 100644 index 0000000..3478b3d --- /dev/null +++ b/examples/github/easy-github-repository-create-repository/main.tf @@ -0,0 +1,24 @@ +terraform { + required_version = ">=0.13" + required_providers { + github = { + source = "integrations/github" + version = "~> 6.0" + } + } +} + +provider "github" { + token = var.token +} + +variable "token" { # to be exported as an environment variable + description = "GitHub token for authentication" + type = string +} + +resource "github_repository" "my_repo" { + name = "my-awesome-repo" + visibility = "public" + description = "This is a repository created with Terraform" +}