From 7978fd22ac489a489ef0b5bed9f54b4f3078ee6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Fri, 15 Apr 2022 11:57:32 +0200 Subject: [PATCH] refactor(ci) : .gitlab-ci.yml : use DEV_xx/PROD_xx variables from Gitlab CI/CD environment refs #505 --- .gitlab-ci.yml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2c4534eb..196f45238 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,13 +10,20 @@ stages: - releases-version variables: +# from Gitlab CI/CD environment variables : +# - development server : +# DEV_HOST : deployment server hostname +# DEV_LOGIN : user on deployment server +# DEV_PATH : path base on deployment server +# - production server : +# PROD_HOST : deployment server hostname +# PROD_LOGIN : user on deployment server +# PROD_PASS : password for user on deployment server +# PROD_PATH : path base on deployment server LC_ALL: C.UTF-8 ANDROID_HOME: "/usr/local/android-sdk" # should already be defined in the Docker image ANDROID_SDK_ROOT: "/usr/local/android-sdk" # should already be defined in the Docker image - DEPLOY_HOST_LOGIN: "nghyd@aubes" - DEPLOY_URL: "/var/www/html/cassiopee" - DEPLOY_STABLE_URL: "/var/www/cassiopee-production" - RELEASES_URL: "$DEPLOY_STABLE_URL/cassiopee-releases" + RELEASES_PATH: "$PROD_PATH/cassiopee-releases" before_script: # load private key from GitLab CI variable, to deploy on Aubes server @@ -91,7 +98,7 @@ clean-stale-branches: - tags - web script: - - ./scripts/remove-stale-branches.sh $DEPLOY_HOST_LOGIN $DEPLOY_URL + - ./scripts/remove-stale-branches.sh $DEV_LOGIN@$DEV_HOST $DEV_PATH deploy-dev: stage: deploy-dev @@ -103,7 +110,7 @@ deploy-dev: - build script: # Copie de la branche / du tag - - rsync --delete -a "dist/" "$DEPLOY_HOST_LOGIN:$DEPLOY_URL/$CI_COMMIT_REF_NAME" + - rsync --delete -a "dist/" "$DEV_LOGIN@$DEV_HOST:$DEV_PATH/$CI_COMMIT_REF_NAME" deploy-prod: stage: deploy-prod @@ -114,9 +121,9 @@ deploy-prod: - build script: # Copie de la branche production - - rsync --delete -a "dist/" "$DEPLOY_HOST_LOGIN:$DEPLOY_STABLE_URL/" + - rsync --delete -a "dist/" "$PROD_LOGIN@$PROD_HOST:$PROD_PATH/" # Modification du dossier base href - - ssh $DEPLOY_HOST_LOGIN "sed -i 's:/cassiopee/stable/:/:g' $DEPLOY_STABLE_URL/index.html" + - ssh $PROD_LOGIN@PROD_HOST "sed -i 's:/cassiopee/stable/:/:g' $PROD_PATH/index.html" releases-nightly: stage: releases-nightly @@ -124,11 +131,7 @@ releases-nightly: - schedules dependencies: [] script: - - npm run release-all - - find release -name "fr.irstea.cassiopee_*.deb" -exec scp "{}" $DEPLOY_HOST_LOGIN:$RELEASES_URL/linux-nightly.deb \; - - find release -name "Cassio*Setup*.exe" -exec scp "{}" $DEPLOY_HOST_LOGIN:$RELEASES_URL/windows-nightly.exe \; - - find release -name "Cassio*-mac.zip" -exec scp "{}" $DEPLOY_HOST_LOGIN:$RELEASES_URL/macos-nightly.zip \; - - find release -name "cassiopee-*.apk" -exec scp "{}" $DEPLOY_HOST_LOGIN:$RELEASES_URL/android-nightly.apk \; + - ./scripts/release-version.sh nightly $PROD_LOGIN $PROD_HOST $RELEASES_PATH releases-version: stage: releases-version @@ -137,4 +140,4 @@ releases-version: - $CI_COMMIT_REF_NAME =~ /^[0-9]+\.[0-9]+\.[0-9]+$/ # version tag dependencies: [] script: - - ./scripts/release-version.sh $CI_COMMIT_REF_NAME $DEPLOY_HOST_LOGIN $RELEASES_URL + - ./scripts/release-version.sh $CI_COMMIT_REF_NAME $PROD_LOGIN $PROD_HOST $RELEASES_PATH -- GitLab