|
|
@@ -0,0 +1,78 @@
|
|
|
+#!/bin/bash
|
|
|
+
|
|
|
+tput setaf 3
|
|
|
+echo "PIC : Quel environnement souhaitez-vous pousser ?"
|
|
|
+select pic in r7 preprod "r7 & preprod" prod
|
|
|
+do
|
|
|
+ case $pic in
|
|
|
+ "r7")
|
|
|
+ ENV="r7.cms.cse-invent.com"
|
|
|
+ BRANCH="r7"
|
|
|
+ ORIGIN="dev"
|
|
|
+ ;;
|
|
|
+ "preprod")
|
|
|
+ ENV="pp.cms.cse-invent.com"
|
|
|
+ BRANCH="preprod"
|
|
|
+ ORIGIN="r7"
|
|
|
+ ;;
|
|
|
+ "r7 & preprod")
|
|
|
+ MULTI_ENV=true
|
|
|
+ ;;
|
|
|
+ "prod")
|
|
|
+ ENV="cms.cse-invent.com"
|
|
|
+ BRANCH="master"
|
|
|
+ ORIGIN="preprod"
|
|
|
+ ;;
|
|
|
+ *)
|
|
|
+ tput setaf 1
|
|
|
+ echo "Cette entrée n'existe pas"
|
|
|
+ tput setaf 7
|
|
|
+ break
|
|
|
+ ;;
|
|
|
+ esac
|
|
|
+
|
|
|
+ if [ "$MULTI_ENV" = true ]; then
|
|
|
+ for env in "r7.cms.cse-invent.com:r7:dev" "pp.cms.cse-invent.com:preprod:r7"; do
|
|
|
+ IFS=':' read -r ENV BRANCH ORIGIN <<< "$env"
|
|
|
+ tput setaf 2
|
|
|
+ echo "Environnement : $ENV"
|
|
|
+ tput setaf 7
|
|
|
+ read -p "Voulez-vous pousser sur $ENV ? [y/n] " -n 1 -r
|
|
|
+ echo
|
|
|
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
+ cd /var/www || exit
|
|
|
+ sudo chown -R debian:debian "$ENV/"
|
|
|
+ cd "$ENV" || exit
|
|
|
+ # Forcer l'URL du remote sur le dépôt unique
|
|
|
+ git remote set-url origin git@git.cse-invent.com:product/cms.events.git
|
|
|
+ git checkout "$BRANCH"
|
|
|
+ git pull origin "$ORIGIN"
|
|
|
+ git push
|
|
|
+ cd ..
|
|
|
+ sudo chown -R www-data:www-data "$ENV/"
|
|
|
+ fi
|
|
|
+ done
|
|
|
+ else
|
|
|
+ tput setaf 2
|
|
|
+ echo "Environnement : $ENV"
|
|
|
+ tput setaf 7
|
|
|
+ read -p "Voulez-vous pousser sur l'environnement sélectionné ? [y/n] " -n 1 -r
|
|
|
+ echo
|
|
|
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
|
+ cd /var/www || exit
|
|
|
+ sudo chown -R debian:debian "$ENV/"
|
|
|
+ cd "$ENV" || exit
|
|
|
+ # Forcer l'URL du remote sur le dépôt unique
|
|
|
+ git remote set-url origin git@git.cse-invent.com:product/cms.events.git
|
|
|
+ git checkout "$BRANCH"
|
|
|
+ git pull origin "$ORIGIN"
|
|
|
+ git push
|
|
|
+ cd ..
|
|
|
+ sudo chown -R www-data:www-data "$ENV/"
|
|
|
+ fi
|
|
|
+ fi
|
|
|
+
|
|
|
+ break
|
|
|
+done
|
|
|
+
|
|
|
+tput setaf 7 # Reset color at the end of the script.
|