From 41a677e0e99c12ca5a070f5feecc6c8b74bf8c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 25 Apr 2022 16:50:52 +0200 Subject: [PATCH] fix(ci) : use jalhyd branch name to provide cache key through variable refs #526 --- .gitlab-ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e5f7049a..1b59fb1be 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,17 +34,19 @@ before_script: # disable console prompt for host checking - mkdir -p ~/.ssh - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config - -cache: - key: - files: - - jalhyd_branch - - package.json - paths: - - node_modules/ + # set cache key + - CACHE_KEY=$(cat jalhyd_branch) + - if [ "$CI_COMMIT_REF_NAME" = "master" ]; then CACHE_KEY="master"; fi + - if [ "$CI_COMMIT_REF_NAME" = "devel" ]; then CACHE_KEY="devel"; fi + - echo CACHE_KEY $CACHE_KEY + - export CACHE_KEY jalhyd: stage: jalhyd + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - pushes - tags @@ -66,6 +68,10 @@ jalhyd: install: stage: install + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - pushes - tags @@ -77,6 +83,10 @@ install: test: stage: test + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - tags - schedules @@ -86,6 +96,10 @@ test: build: stage: build + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - pushes - tags @@ -100,6 +114,10 @@ build: clean-stale-branches: stage: clean-stale-branches + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - pushes - tags @@ -109,6 +127,10 @@ clean-stale-branches: deploy-dev: stage: deploy-dev + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - pushes - tags @@ -121,6 +143,10 @@ deploy-dev: deploy-prod: stage: deploy-prod + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: variables: - $CI_COMMIT_REF_NAME == "stable" @@ -131,6 +157,10 @@ deploy-prod: releases-nightly: stage: releases-nightly + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: - schedules except: @@ -142,6 +172,10 @@ releases-nightly: releases-version: stage: releases-version + cache: + key: "$CACHE_KEY" + paths: + - node_modules/ only: variables: - $CI_COMMIT_REF_NAME =~ /^[0-9]+\.[0-9]+\.[0-9]+$/ # version tag -- GitLab