diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 017c0f1..57f1abd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index 8d21c5e..9d25218 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ terraform.rc .terraform.lock.hcl localTerraform.sh setLocalVariables.sh +*.pem diff --git a/main.tf b/main.tf index 874bb04..7574d76 100644 --- a/main.tf +++ b/main.tf @@ -10,6 +10,10 @@ terraform { source = "gitlabhq/gitlab" version = "16.9.1" } + github = { + source = "integrations/github" + version = "6.0.0" + } } } @@ -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" +} diff --git a/modules/github/global_labels/main.tf b/modules/github/global_labels/main.tf new file mode 100644 index 0000000..b33f361 --- /dev/null +++ b/modules/github/global_labels/main.tf @@ -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 +} diff --git a/modules/github/global_labels/variables.tf b/modules/github/global_labels/variables.tf new file mode 100644 index 0000000..df61185 --- /dev/null +++ b/modules/github/global_labels/variables.tf @@ -0,0 +1,3 @@ +variable "repository" { + type = string +} diff --git a/system/github/main.tf b/system/github/main.tf new file mode 100644 index 0000000..f748ca1 --- /dev/null +++ b/system/github/main.tf @@ -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 +} diff --git a/variables.tf b/variables.tf index 51a1616..7096079 100644 --- a/variables.tf +++ b/variables.tf @@ -12,3 +12,8 @@ variable "gitlab_api_token" { type = string sensitive = true } + +variable "github_app_key" { + type = string + sensitive = true +}