From 192b621803cf75ed3b8d5281f177bfc656b53e56 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Thu, 7 Sep 2023 01:28:18 +0200
Subject: [PATCH] ci(gitlab-ci): Separate earthly to allow outside imports

---
 images/.utils/gitlab-ci.yaml      | 29 ++++++-----------------------
 images/.utils/gitlab-earthly.yaml | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 23 deletions(-)
 create mode 100644 images/.utils/gitlab-earthly.yaml

diff --git a/images/.utils/gitlab-ci.yaml b/images/.utils/gitlab-ci.yaml
index 7efcaf881..7d7c2e6e9 100644
--- a/images/.utils/gitlab-ci.yaml
+++ b/images/.utils/gitlab-ci.yaml
@@ -1,4 +1,9 @@
-.container-matrix:
+include:
+  - local: 'images/.utils/gitlab-earthly.yaml'
+
+container-build:
+  stage: build
+  extends: .earthly
   parallel:
     matrix:
       - IMAGE:
@@ -8,26 +13,6 @@
           - synadm
           - query-exposer
           - findmydevice-server
-
-earthly:
-  stage: build
-  image: docker.io/earthly/earthly:v0.7.17
-  extends: .container-matrix
-  variables:
-    DOCKER_HOST: tcp://docker:2375
-    FORCE_COLOR: 1
-    EARTHLY_EXEC_CMD: "/bin/sh"
-    EARTHLY_SERVER_ADDRESS: localhost
-    EARTHLY_GRPC_ADDRESS: localhost
-  services:
-    - docker:dind
-  before_script:
-      - docker run --privileged --rm tonistiigi/binfmt --install all
-      - earthly config global.disable_analytics true
-      - earthly config global.disable_log_sharing true
-      - earthly account logout
-      - earthly bootstrap
-      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
   script:
     - cd images/${IMAGE}
     - |
@@ -41,8 +26,6 @@ earthly:
         export BUILD_ARGS="${BUILD_ARGS} --tag=$CI_COMMIT_REF_SLUG --latest=false"
       fi
     - earthly --ci --allow-privileged --push ${ARGS} +container --registry=quay.io/shivering-isles/${IMAGE} ${BUILD_ARGS}
-  tags:
-    - privileged
   rules:
     - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push"'
       changes:
diff --git a/images/.utils/gitlab-earthly.yaml b/images/.utils/gitlab-earthly.yaml
new file mode 100644
index 000000000..dd6a6bec2
--- /dev/null
+++ b/images/.utils/gitlab-earthly.yaml
@@ -0,0 +1,19 @@
+.earthly:
+  image: docker.io/earthly/earthly:v0.7.17
+  variables:
+    DOCKER_HOST: tcp://docker:2375
+    FORCE_COLOR: 1
+    EARTHLY_EXEC_CMD: "/bin/sh"
+    EARTHLY_SERVER_ADDRESS: localhost
+    EARTHLY_GRPC_ADDRESS: localhost
+  services:
+    - docker:dind
+  before_script:
+      - docker run --privileged --rm tonistiigi/binfmt --install all
+      - earthly config global.disable_analytics true
+      - earthly config global.disable_log_sharing true
+      - earthly account logout
+      - earthly bootstrap
+      - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
+  tags:
+    - privileged
\ No newline at end of file
-- 
GitLab