Skip to content

Commit

Permalink
Add github organization management
Browse files Browse the repository at this point in the history
  • Loading branch information
Taucher2003 committed Mar 15, 2024
1 parent bfe1b22 commit 8f805a9
Show file tree
Hide file tree
Showing 7 changed files with 69 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"
}
23 changes: 23 additions & 0 deletions modules/github/global_labels/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
terraform {
required_providers {
github = {
source = "integrations/github"
version = "6.0.0"
}
}
}

locals {
labels = {
test = tomap({ description = "testing", color = "ff8000" })
}
}

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 8f805a9

Please sign in to comment.