From f075272fe52f36a4beba0b4f7cc37e57cbbfc5ef Mon Sep 17 00:00:00 2001
From: Zedic Birchler <zedic1@gmail.com>
Date: Fri, 21 Mar 2025 01:58:58 -0500
Subject: [PATCH] feat: add rules input to module-release.yml

Changelog: added
---
 templates/module-release.yml                        | 10 ++++++++++
 tests/integration-tests/ModuleRelease.gitlab-ci.yml |  6 +-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/templates/module-release.yml b/templates/module-release.yml
index e3ad723..15fc96b 100644
--- a/templates/module-release.yml
+++ b/templates/module-release.yml
@@ -30,11 +30,21 @@ spec:
         e.g. '0.1.0'
       default: ${CI_COMMIT_TAG}
 
+    rules:
+      # FIXME: eventually, we'll want to define `null` as the default,
+      # but this is NOT support yet, see
+      # https://gitlab.com/gitlab-org/gitlab/-/issues/440468
+      default: [{when: on_success}]
+      type: array
+      description: 'Defines the `rules` of the job.'
+
+
 ---
 
 '$[[ inputs.as ]]':
   stage: $[[ inputs.stage ]]
   image: debian:bookworm-slim
+  rules: $[[ inputs.rules ]]
   variables:
     TAR_FILENAME: /tmp/${CI_PROJECT_NAME}-${CI_COMMIT_SHA}.tgz
     GITLAB_TOFU_ROOT_DIR: $[[ inputs.root_dir ]]
diff --git a/tests/integration-tests/ModuleRelease.gitlab-ci.yml b/tests/integration-tests/ModuleRelease.gitlab-ci.yml
index 6c80fcc..9f8d087 100644
--- a/tests/integration-tests/ModuleRelease.gitlab-ci.yml
+++ b/tests/integration-tests/ModuleRelease.gitlab-ci.yml
@@ -8,14 +8,10 @@ include:
       root_dir: $TEST_GITLAB_TOFU_ROOT_DIR/modules/random-pet
       module_system: $MODULE_SYSTEM
       module_version: $MODULE_VERSION
+      rules: [{when: always}]
 
 stages: [release, destroy]
 
-# Required to run everything immediately, instead of manually.
-
-module-release:
-  rules: [{when: always}]
-
 delete-module:
   stage: destroy
   image: curlimages/curl:latest
-- 
GitLab