Skip to content

Commit

Permalink
Add org member module (feat)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukiffer committed Jan 3, 2023
1 parent e396568 commit 0dadcc4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
27 changes: 27 additions & 0 deletions modules/github-org-member/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# github-org-member

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.26 |
| <a name="requirement_github"></a> [github](#requirement\_github) | >= 5.7.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_github"></a> [github](#provider\_github) | >= 5.7.0 |

## Resources

| Name | Type |
|------|------|
| [github_membership.member](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/membership) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_role"></a> [role](#input\_role) | The role of the user in the org. One of `admin` or `member`. | `string` | n/a | yes |
| <a name="input_username"></a> [username](#input\_username) | The GitHub username of the user being added to the org. | `string` | n/a | yes |
15 changes: 15 additions & 0 deletions modules/github-org-member/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_version = ">= 0.12.26"

required_providers {
github = {
source = "integrations/github"
version = ">= 5.7.0"
}
}
}

resource "github_membership" "member" {
username = var.username
role = var.role == "admin" ? "admin" : "member"
}
18 changes: 18 additions & 0 deletions modules/github-org-member/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ---------------------------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ---------------------------------------------------------------------------------------------------------------------

variable "username" {
description = "The GitHub username of the user being added to the org."
type = string
}

variable "role" {
description = "The role of the user in the org. One of `admin` or `member`."
type = string

validation {
condition = contains(["admin", "member"], var.role)
error_message = "Role must be either `admin` or `member`."
}
}

0 comments on commit 0dadcc4

Please sign in to comment.