From 78b63cd1db47bc20e36a048d1cf552cf87a4d320 Mon Sep 17 00:00:00 2001
From: Michael Blaschek <michael.blaschek@univie.ac.at>
Date: Mon, 23 Jan 2023 15:41:52 +0000
Subject: [PATCH] added cache to jobs, build

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

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 43ea29d..0c17c77 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,7 +1,14 @@
-#image: localhost:5000/mkdocs-imgw
 image: python:3.9-buster
 
-# Install all required packages
+variables:
+    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
+
+# Cache between jobs in the same branch
+cache:
+    - key: $CI_COMMIT_REF_SLUG
+    - paths:
+        - .cache/pip
+
 
 stages:
     - build
@@ -9,9 +16,12 @@ stages:
 
 build:
     rules:
+        # only run pipeline when build is in the commit message
         - if: $CI_COMMIT_MESSAGE =~ /.*build.*/
     stage: build
+
     before_script:
+        # Install all required packages
         - pip install -r requirements.txt
     script:
         # --strict is too strict :)
@@ -19,6 +29,10 @@ build:
     artifacts:
         paths:
             - mkdocs.log
+    cache:
+        key: build-cache
+        paths:
+            - site/
 
 deploy:
     stage: deploy
@@ -28,3 +42,7 @@ deploy:
         - apt-get update -qq && apt-get install -y -qq sshpass openssh-client
     script:
         - sshpass -p "$WOLKE_PASSWORD" scp -oStrictHostKeyChecking=no -r ./site/ $WOLKE_USER@wolke.img.univie.ac.at:/var/www/html/documentation/general/
+    cache:
+        key: build-cache
+        paths:
+            - site/
-- 
GitLab