Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions modules/gitlab/runner_support_webhook/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
terraform {
required_providers {
gitlab = {
source = "gitlabhq/gitlab"
version = "18.5.0"
}
}
}

data "gitlab_project_variable" "runner_support_token" {
project = "code0-tech/secret-manager"
key = "GITHUB_RUNNER_SUPPORT_TOKEN"
}

resource "gitlab_project_hook" "runner_support" {
project = var.project
url = "https://api.github.com/repos/code0-tech/monoceros/actions/workflows/${var.runner_type}.yml/dispatches"

push_events = false
pipeline_events = true

custom_webhook_template = jsonencode(
{
"ref": "main",
"inputs": {
"project": "{{project.id}}"
}
}
)

custom_headers = [
{
key = "Authorization"
value = "Bearer ${data.gitlab_project_variable.runner_support_token.value}"
}
]
}
7 changes: 7 additions & 0 deletions modules/gitlab/runner_support_webhook/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
variable "runner_type" {
type = string
}

variable "project" {
type = string
}
53 changes: 26 additions & 27 deletions system/gitlab/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,36 @@ terraform {
}
}

data "gitlab_project_variable" "runner_support_token" {
project = "code0-tech/secret-manager"
key = "GITHUB_RUNNER_SUPPORT_TOKEN"
module "runner_support_main" {
source = "../../modules/gitlab/runner_support_webhook"

for_each = toset([
"code0-tech/development/sagittarius",
"code0-tech/development/reticulum",
])

project = each.value
runner_type = "runner-support"
}

resource "gitlab_project_hook" "runner_support" {
for_each = {
"code0-tech/development/sagittarius": "runner-support",
"code0-tech/development/reticulum": "runner-support",
"code0-tech/infrastructure/pyxis": "runner-support-infra",
}
module "runner_support_infra" {
source = "../../modules/gitlab/runner_support_webhook"

project = each.key
url = "https://api.github.com/repos/code0-tech/monoceros/actions/workflows/${each.value}.yml/dispatches"
for_each = toset([
"code0-tech/infrastructure/pyxis"
])

push_events = false
pipeline_events = true
project = each.value
runner_type = "runner-support-infra"
}

custom_webhook_template = jsonencode(
{
"ref": "main",
"inputs": {
"project": "{{project.id}}"
}
}
)
module "runner_support_arm" {
source = "../../modules/gitlab/runner_support_webhook"

custom_headers = [
{
key = "Authorization"
value = "Bearer ${data.gitlab_project_variable.runner_support_token.value}"
}
]
for_each = toset([
"code0-tech/development/reticulum"
])

project = each.value
runner_type = "runner-support-arm"
}