From 2d8d734374173f69bec9c5ff9538ecb25915fae7 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Wed, 23 Nov 2022 20:03:37 +0100
Subject: [PATCH] ci(images): Reduce builds by only check for changes from
 default branch

This patch tries to use the GitLab CI feature that allows to
detect changes from a specific branch, in this case the default
branch, and this way hopefully reduces the amount of
unnecessarily build images that originate from gitlab starting
a full build by default on a new branch.

References:
https://docs.gitlab.com/15.4/ee/ci/yaml/#ruleschangescompare_to
---
 charts/.utils/gitlab-ci.yaml | 4 +++-
 images/.utils/gitlab-ci.yaml | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/charts/.utils/gitlab-ci.yaml b/charts/.utils/gitlab-ci.yaml
index 2f2cd4d59..48f5fae73 100644
--- a/charts/.utils/gitlab-ci.yaml
+++ b/charts/.utils/gitlab-ci.yaml
@@ -36,4 +36,6 @@ chart-helm-unittest:
   rules:
     - if: '$CI_PIPELINE_SOURCE == "push"'
       changes:
-        - charts/${CHART}/**/*
+        paths:
+          - charts/${CHART}/**/*
+        compare_to: $CI_DEFAULT_BRANCH
diff --git a/images/.utils/gitlab-ci.yaml b/images/.utils/gitlab-ci.yaml
index ae28fa001..32accce50 100644
--- a/images/.utils/gitlab-ci.yaml
+++ b/images/.utils/gitlab-ci.yaml
@@ -54,7 +54,9 @@ container-build-dev:
   rules:
     - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
       changes:
-        - images/${IMAGE}/**/*
-        - images/.utils/*
+        paths:
+          - images/${IMAGE}/**/*
+          - images/.utils/*
+        compare_to: $CI_DEFAULT_BRANCH
   tags:
     - hetzner
-- 
GitLab