From 4ec0b5e778c51ac267ee3dc4ffc6196976f30267 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Wed, 27 Aug 2025 12:25:06 +0200 Subject: [PATCH] [Close #159] feat: support github action variables --- secrets.tf | 12 ++++++++++++ test/unit-complete/main.tf | 4 ++++ test/unit-complete/variables.tf | 12 ++++++++++++ variables.tf | 12 ++++++++++++ 4 files changed, 40 insertions(+) diff --git a/secrets.tf b/secrets.tf index f8f494fa..60328eae 100644 --- a/secrets.tf +++ b/secrets.tf @@ -1,3 +1,15 @@ +# --------------------------------------------------------------------------------------------------------------------- +# Action Variables +# --------------------------------------------------------------------------------------------------------------------- +resource "github_actions_variable" "repository_variable" { + for_each = var.plaintext_variables + + repository = github_repository.repository.name + variable_name = each.key + value = try(each.value, null) +} + + # --------------------------------------------------------------------------------------------------------------------- # Action Secrets # --------------------------------------------------------------------------------------------------------------------- diff --git a/test/unit-complete/main.tf b/test/unit-complete/main.tf index f307097a..58041942 100644 --- a/test/unit-complete/main.tf +++ b/test/unit-complete/main.tf @@ -64,6 +64,10 @@ module "repository" { github_team.team.id ] + plaintext_variables = { + (var.variable_name) = var.variable_text + } + plaintext_secrets = { (var.secret_name) = var.secret_text } diff --git a/test/unit-complete/variables.tf b/test/unit-complete/variables.tf index 55b155fe..6997ad34 100644 --- a/test/unit-complete/variables.tf +++ b/test/unit-complete/variables.tf @@ -186,6 +186,18 @@ variable "secret_text" { default = "42" } +variable "variable_name" { + description = "The name of the variable." + type = string + default = "MY_VAR" +} + +variable "variable_text" { + description = "The value of the variable." + type = string + default = "42" +} + variable "encrypted_secret_name" { description = "The name of the secret." type = string diff --git a/variables.tf b/variables.tf index 7599034c..b2968cae 100644 --- a/variables.tf +++ b/variables.tf @@ -494,6 +494,18 @@ variable "webhooks" { # }] } +variable "plaintext_variables" { + description = "(Optional) Configuring actions variables. For details please check: https://www.terraform.io/docs/providers/github/r/actions_variable" + type = map(string) + + # Example: + # plaintext_variable = { + # "MY_VAR" = "42" + # } + + default = {} +} + variable "plaintext_secrets" { description = "(Optional) Configuring actions secrets. For details please check: https://www.terraform.io/docs/providers/github/r/actions_secret" type = map(string)