From 1060d518cd7dc80ab096d43476da2de17553c02a Mon Sep 17 00:00:00 2001
From: Benoit Donneaux <benoit@leastauthority.com>
Date: Thu, 25 Jan 2024 11:21:04 +0100
Subject: [PATCH] Use a separate branch to deploy hro-cloud

Signed-off-by: Benoit Donneaux <benoit@leastauthority.com>
---
 .gitlab-ci.yml                  | 13 ++++++++++++-
 ci-tools/update-production      |  4 ++--
 morph/grid/hro-cloud/grid.nix   |  2 +-
 nixos/modules/update-deployment |  4 ++++
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 23205d51..26c619f0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -178,7 +178,7 @@ deploy-to-hro-cloud:
     # https://docs.gitlab.com/ee/ci/yaml/index.html#rulesif
     # https://docs.gitlab.com/ee/ci/jobs/job_control.html#cicd-variable-expressions
     # https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
-    - if: '$CI_COMMIT_BRANCH == "production"'
+    - if: '$CI_COMMIT_BRANCH == "hro-cloud"'
 
   environment:
     # See notes in `update-staging`.
@@ -208,3 +208,14 @@ update-production:
               "$CI_PROJECT_ID" \
               "develop" \
               "production"
+
+update-hro-cloud:
+  <<: *RUN_ON_SCHEDULE
+  stage: "build"
+  script:
+    - |
+      ./ci-tools/update-production \
+              "$CI_SERVER_URL" \
+              "$CI_PROJECT_ID" \
+              "develop" \
+              "hro-cloud"
diff --git a/ci-tools/update-production b/ci-tools/update-production
index 7892bce0..a3c4cd64 100755
--- a/ci-tools/update-production
+++ b/ci-tools/update-production
@@ -78,8 +78,8 @@ describe_update() {
     local TARGET_BRANCH=$1
     shift
 
-    # Since production production (target) should not diverge from develop
-    # (source) it is fine to use `..` instead of `...` in the git ranges here.
+    # Since the target (production or hro-cloud) should not diverge from the source
+    # (develop) it is fine to use `..` instead of `...` in the git ranges here.
     # `...` encounters problems related to discovering the merge base because
     # of the way GitLab manages the git checkout on CI (I think).
 
diff --git a/morph/grid/hro-cloud/grid.nix b/morph/grid/hro-cloud/grid.nix
index 16fb1d4f..33a441cc 100644
--- a/morph/grid/hro-cloud/grid.nix
+++ b/morph/grid/hro-cloud/grid.nix
@@ -24,7 +24,7 @@ let
     # Configure deployment management authorization for all systems in the grid.
     services.private-storage.deployment = {
       authorizedKey = builtins.readFile "${config.grid.publicKeyPath}/deploy_key.pub";
-      gridName = "production";
+      gridName = "hro-cloud";
     };
   };
   payments = {
diff --git a/nixos/modules/update-deployment b/nixos/modules/update-deployment
index cd41a236..ddac5752 100755
--- a/nixos/modules/update-deployment
+++ b/nixos/modules/update-deployment
@@ -17,6 +17,10 @@ case "${GRIDNAME}" in
 	BRANCH="develop"
 	;;
 
+    "hro-cloud")
+	BRANCH="hro-cloud"
+	;;
+
     "production")
 	BRANCH="production"
 	;;
-- 
GitLab