From 0e4ac06999dcbb283475aa7df2318fc5ca593c31 Mon Sep 17 00:00:00 2001
From: Lukas Malte Monnerjahn <lukasmalte.monnerjahn@dataport.de>
Date: Wed, 2 Apr 2025 16:28:33 +0200
Subject: [PATCH] pipeline deploys to gitops/test on commit_tag

---
 .gitlab-ci.yml | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 627d9250..31dc1d96 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -165,7 +165,7 @@ gitops-snapshot:
     - yq -i ".afm_adapter.helm.version = \"${PROJECT_VERSION}-main-${CI_COMMIT_SHORT_SHA}\"" ${VALUES_FILE}
     - yq -i ".fs_adapter.helm.version = \"${PROJECT_VERSION}-main-${CI_COMMIT_SHORT_SHA}\"" ${FS_VALUES_FILE}
     - git add ${VALUES_FILE} ${FS_VALUES_FILE}
-    - git commit -m "code-sh GitLab CI rollout ${environment} ${PROJECT_ARTIFACTID} version ${SNAPSHOT_TAG}-${CI_COMMIT_SHORT_SHA}"
+    - git commit -m "code-sh GitLab CI rollout ${GITOPS_ENVIRONMENT} ${PROJECT_ARTIFACTID} version ${SNAPSHOT_TAG}-${CI_COMMIT_SHORT_SHA}"
     - git push https://${GITEA_USER}:${GITEA_TOKEN}@git.ozg-sh.de/ozgcloud-devops/gitops.git
   only:
    - main
@@ -208,3 +208,28 @@ push-release-helm-nexus:
   artifacts:
     paths:
       - "*.tgz"
+
+gitops-release:
+  stage: gitops
+  variables:
+    GITOPS_ENVIRONMENT: test
+    VALUES_FILE_NAME: afm-adapter-values.yaml
+    FORMSOLUTIONS_VALUES_FILE_NAME: fs-adapter-values.yaml
+    VALUES_FILE: ${GITOPS_ENVIRONMENT}/application/values/${VALUES_FILE_NAME}
+    FS_VALUES_FILE: ${GITOPS_ENVIRONMENT}/application/values/${FORMSOLUTIONS_VALUES_FILE_NAME}
+  before_script:
+    - apk add --no-cache git yq  # yq-go in newer versions of alpine (from 3.20 on)
+    - git config --global user.name "${GITEA_USER}"
+    - git config --global user.email "${GITEA_USER_EMAIL}"
+    - !reference [.get-version, before_script]
+  script:
+    - git clone https://${GITEA_USER}:${GITEA_TOKEN}@git.ozg-sh.de/ozgcloud-devops/gitops.git
+    - cd gitops
+    - yq -i ".afm_adapter.image.tag = \"${CI_COMMIT_TAG}\"" ${VALUES_FILE}
+    - yq -i ".afm_adapter.helm.version = \"${CI_COMMIT_TAG}\"" ${VALUES_FILE}
+    - yq -i ".fs_adapter.helm.version = \"${CI_COMMIT_TAG}\"" ${FS_VALUES_FILE}
+    - git add ${VALUES_FILE} ${FS_VALUES_FILE}
+    - git commit -m "code-sh GitLab CI rollout ${GITOPS_ENVIRONMENT} ${PROJECT_ARTIFACTID} version ${CI_COMMIT_TAG}"
+    - git push https://${GITEA_USER}:${GITEA_TOKEN}@git.ozg-sh.de/ozgcloud-devops/gitops.git
+  rules:
+    - if: $CI_COMMIT_TAG
-- 
GitLab