From ff5b8d73ce9b6a8aff76ea51e795777e6e4c304b Mon Sep 17 00:00:00 2001
From: Kevin Daudt <kdaudt@alpinelinux.org>
Date: Fri, 1 Sep 2023 10:38:47 +0000
Subject: [PATCH] ci: switch to rules

`only` has been deprecated and gitlab recommends to use rules instead,
which are more flexible.

Add a global workflow and change the `only` specifications to `rules`.
---
 .gitlab-ci.yml | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ec10a95f261d..4a8bb911ac39 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,6 +6,11 @@ variables:
   GIT_STRATEGY: clone
   GIT_DEPTH: "500"
 
+# only rune pipelines for merge requests or when tags are pushed  (for triggers)
+workflow:
+  - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+  - if: $CI_COMMIT_TAG
+
 lint:
   stage: verify
   image: alpinelinux/apkbuild-lint-tools:latest
@@ -13,8 +18,8 @@ lint:
   script:
     - lint
   allow_failure: true
-  only:
-    - merge_requests
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
   tags:
     - docker-alpine
     - x86_64
@@ -32,8 +37,8 @@ lint:
       - logs/
     expire_in: 1 day
     when: always
-  only:
-    - merge_requests
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
 
 build-x86_64:
   extends: .build
@@ -119,8 +124,8 @@ build-riscv64-emulated:
 
 trigger_build_image:
   stage: trigger
-  only:
-    - tags
+  rules:
+    - if: $CI_COMMIT_TAG
   variables:
     APORTS_TAG: $CI_COMMIT_TAG
   trigger:
-- 
GitLab