Using Terraform's GitHub Provider to operate GitHub
Before using it, you need to configure the authentication information for accessing GitHub's API, such as GitHub Personal Access Token
Here's an example of using Terraform to manipulate GitHub:
# Configure GitHub Provider
provider "github" {
token = "GITHUB_PERSONAL_ACCESS_TOKEN"
}
# Create a new GitHub Repository
resource "github_repository" "example" {
name = "example-repo"
description = "This is an example repository"
visibility = "public"
}
# Add a Collaborators
resource "github_repository_collaborator" "example" {
repository = github_repository.example.name
username = "example-collaborator"
permission = "push"
}
In the example, we use GitHub Provider to create a new public warehouse and add a Collaborator
发表评论 取消回复