From 8519f358a1a95a22ef24eb8f4949892bcb8c5921 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Tue, 12 Sep 2023 13:42:46 +0200
Subject: [PATCH] disable expiry for artifacts from tag pipelines

---
 .gitlab-ci.yml | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d304f1241..d1fb65e97 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -7,6 +7,7 @@ stages:
   - step-D
   - step-E
   - step-F
+  - post-deploy
 
 # List global variables
 variables:
@@ -690,3 +691,24 @@ after-tag-creation:
     - test "$TAG" != "$VERSION" && echo "ERROR --> There is a TAG/VERSION mismatch" && exit 1
     - echo "OK."
 
+
+
+###########
+# A special job, only meant to change the default expiry policy 
+# from '1day' to 'never' for jobs which run on 'tags'.
+# This is done to keep the artifacts from tags indefinitely,
+# while deleting all the others.
+##########
+persist-tag-artifacts:
+  # Use this job to specify artifacts that should never expire for tag pipelines.
+  stage: post-deploy
+  rules:
+    - if: '$CI_COMMIT_TAG != null'
+  script:
+    - echo "Persisting artifacts for tag pipelines"
+  artifacts:
+    # Specify artifacts from previous jobs to be persisted indefinitely
+    paths:
+      - install
+    expire_in: never
+
-- 
GitLab