Skip to content

Commit

Permalink
Merge pull request #15 from code0-tech/add-github-management
Browse files Browse the repository at this point in the history
Add github organization management
  • Loading branch information
Taucher2003 authored Mar 15, 2024
2 parents bfe1b22 + 50df3a9 commit 7e2df4a
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
GLPA_TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
GLPA_TF_VAR_cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
GLPA_TF_VAR_gitlab_api_token: ${{ secrets.GL_API_TOKEN }}
GLPA_TF_VAR_github_app_key: ${{ secrets.GH_TF_APP_KEY }}

- name: Find existing comment
uses: peter-evans/find-comment@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,4 @@ terraform.rc
.terraform.lock.hcl
localTerraform.sh
setLocalVariables.sh
*.pem
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ terraform {
source = "gitlabhq/gitlab"
version = "16.9.1"
}
github = {
source = "integrations/github"
version = "6.0.0"
}
}
}

Expand All @@ -22,8 +26,21 @@ provider "gitlab" {
base_url = "https://gitlab.com/api/v4/"
}

provider "github" {
owner = "code0-tech"
app_auth {
id = "832219"
installation_id = "47451228"
pem_file = var.github_app_key
}
}

module "domain" {
source = "./system/domain"
cloudflare_account_id = var.cloudflare_account_id
cloudflare_api_token = var.cloudflare_api_token
}

module "github" {
source = "./system/github"
}
62 changes: 62 additions & 0 deletions modules/github/global_labels/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
terraform {
required_providers {
github = {
source = "integrations/github"
version = "6.0.0"
}
}
}

locals {
labels = {
bug = {
description = "Something isn't working"
color = "d73a4a"
}
dependencies = {
description = "This updates dependency files"
color = "009966"
}
documentation = {
description = "Improvements or additions to documentation"
color = "0075ca"
}
duplicate = {
description = "This issue or pull request already exists"
color = "cfd3d7"
}
enhancement = {
description = "New feature or request"
color = "a2eeef"
}
"good first issue" = {
description = "Good for newcomers"
color = "7057ff"
}
"help wanted" = {
description = "Extra attention is needed"
color = "008672"
}
invalid = {
description = "This doesn't seem right"
color = "e4e669"
}
question = {
description = "Further information is requested"
color = "d876e3"
}
wontfix = {
description = "This will not be worked on"
color = "ffffff"
}
}
}

resource "github_issue_label" "global_labels" {
for_each = local.labels

color = each.value["color"]
name = each.key
description = each.value["description"]
repository = var.repository
}
3 changes: 3 additions & 0 deletions modules/github/global_labels/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "repository" {
type = string
}
19 changes: 19 additions & 0 deletions system/github/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
terraform {
required_providers {
github = {
source = "integrations/github"
version = "6.0.0"
}
}
}

data "github_repositories" "repositories" {
query = "org:code0-tech"
}

module "global_labels" {
source = "../../modules/github/global_labels"

for_each = toset(data.github_repositories.repositories.names)
repository = each.value
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ variable "gitlab_api_token" {
type = string
sensitive = true
}

variable "github_app_key" {
type = string
sensitive = true
}

0 comments on commit 7e2df4a

Please sign in to comment.