# ──────────────────────────────────────────────────────────────
# Quark's Holo-Grid Ledger — Forgejo server (git forge + CI)
# ──────────────────────────────────────────────────────────────

resource "hcloud_server" "forgejo" {
  count       = terraform.workspace == "tooling" ? 1 : 0
  name        = "hologrid-forgejo"
  server_type = var.forgejo_server_type
  location    = var.location
  image       = "ubuntu-24.04"

  ssh_keys = [hcloud_ssh_key.deploy.id]

  firewall_ids = [hcloud_firewall.forgejo[0].id]

  user_data = templatefile("${path.module}/cloud-init/forgejo.yml", {
    ssh_public_key = var.ssh_public_key
    forgejo_domain = var.forgejo_domain
  })

  labels = {
    role        = "forgejo"
    environment = terraform.workspace
  }
}
