This repository is an example of using Terraform provider for GitHub. It does:
- create two teams in organization (admins and users)
- invite people from variables into teams
- create personal repos for users
- enable branch protection so they cannot push to master without review
- add labels to user repos
- Install Terraform (0.10 or newer)
- Copy terraform.tfvars.example to terraform.tfvars
- Fill values in terraform.tfvars. See description below
- Run
terraform init
and thenterraform apply
- After that you can add new users and run apply again
provider "github"
- provider setup. You need to provide organization name and tokenresource "github_team" "admins" and "users"
- create two teams in organizationresource "github_membership" "membership_for_admins and _users"
- define membership in organizationresource "github_team_membership" "admins_membership and _users"
- define membership in teamsresource "github_repository" "users_repos"
- create repos for usersresource "github_branch_protection" "users_repos"
- enable branch protection for user reposresource "github_repository_collaborator" "users_repos"
- add users as collaborators to their reposresource "github_issue_label" "users_repos"
- create labels from list and with count
You need to fill these variables:
gh_token
- token with admin rights to create repo, manage users in team and delete reposgh_org
- name of organizationgh_admins
- list with admin usersgh_users
- list with usual usersgh_labels
- labels listgh_task_count
- quantity of tasks in labels