[gnome-control-center/iainl/coverage-install-udisks2] ci: Rebuild docker images any time a commit touches the dockerfile



commit 1e7c549ad4f4cf548621e5b935350786ae86b2ac
Author: Iain Lane <iainl gnome org>
Date:   Wed Feb 20 11:14:09 2019 +0000

    ci: Rebuild docker images any time a commit touches the dockerfile
    
    Currently they are built from cron, but we can use Gitlab's
    
      only:
        changes:
          - path
    
    support to also trigger on path changes. This is restricted to only work
    for pushes for master, so that branches / merge requests don't attempt
    to rebuild the image.

 .gitlab-ci.yml | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 80e946127..18d67ce6b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -354,6 +354,9 @@ ppc64le:
   only:
     variables:
       - $CRON_TASK == "BUILD_CI_IMAGES"
+    changes:
+      - build-aux/ci/Dockerfile.*
+
 
   script:
     # Skip the build (if requested)
@@ -363,6 +366,19 @@ ppc64le:
         exit 0
       fi
 
+    - |
+      if [[ "${CI_COMMIT_REF_NAME}" != "master" ]]; then
+        echo "== Exiting, will only build CI images when pushing to master. =="
+        exit 0
+      fi
+
+    # Only when we have somewhere to publish to
+    - |
+      if [[ -z "${CI_REGISTRY}${CI_REGISTRY_IMAGE}${CI_REGISTRY_USER}${CI_REGISTRY_PASSWORD}" ]]; then
+        echo "== Exiting, CI registry not configured. =="
+        exit 0
+      fi
+
     # Get multiarch stuff
     - |
       if [[ -n "${TARGET_ARCH}" ]]; then
@@ -373,16 +389,11 @@ ppc64le:
     # Build using the Dockerfile
     - docker build -f "$DOCKERFILE" -t "$CI_REGISTRY_IMAGE:$NAME" .
 
-    # Prepare to publish
+    # Publish
     - docker tag "$CI_REGISTRY_IMAGE:$NAME" "$CI_REGISTRY_IMAGE:job-"$CI_JOB_ID"_$NAME"
     - docker images
     - docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
-
-    # Publish (if running on a schedule)
-    - |
-      if [[ "${CI_PIPELINE_SOURCE}" == "schedule" ]]; then
-        docker push "$CI_REGISTRY_IMAGE"
-      fi
+    - docker push "$CI_REGISTRY_IMAGE"
 
 fedora.dev:
   <<: *create_docker_image


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]