#! /bin/bash COLOR_INFO="\x1B[36m" COLOR_SUCCESS="\x1B[32m" COLOR_WARNING="\x1B[33m" COLOR_FAILURE="\x1B[31m" BOLD_STYLE="\x1B[1m" RESET_COLOR="\x1B[0m" RESET_STYLE="$(tput sgr0)" REQUIREMENTS=" Pré-requis : - Vous devez avoir un compte GitLab sur \"gitlab.cosavostra.com\" et \"gitlab.richemont.com\", avec un accès en écriture. Une clé SSH devra être ajoutée pour chacun de ces environnements. - Assurez-vous d'être connecté(e) sur le VPN fourni par Richemont" echo -e "$( cat << EOM ${BOLD_STYLE} ${REQUIREMENTS} EOM )" echo -e "${RESET_STYLE}" read -ep "$(echo -e "${BOLD_STYLE}${COLOR_WARNING}Voulez-vous continuer? [y/n] ${RESET_STYLE}")" -r if [[ $REPLY =~ ^[Nn]$ ]]; then echo -e "${COLOR_FAILURE}Annulation${RESET_STYLE}" exit elif ! [[ $REPLY =~ ^[YyOo]$ ]]; then echo -e "${COLOR_FAILURE}Réponse invalide. Annulation${RESET_STYLE}" exit fi FOLDER="${HOME}/tmp/richemont-the-lab" # Init folder rm -rf $FOLDER || echo "" mkdir -p $FOLDER # Clone Richemont's project echo echo -e "${BOLD_STYLE}${COLOR_INFO}> Cloning Richemont's repository...${RESET_STYLE}" cd $FOLDER if ! git clone --recursive git@gitlab.richemont.com:scm_project/webplatform/ric/the-lab/ric-thelab.git ./ then echo -e "${BOLD_STYLE}${COLOR_FAILURE}Un problème est survenu. Arrêt.${RESET_STYLE}" exit fi cp -r sources/wp-config.php ./ cp -r sources/.htaccess ./ cp -r sources/robots.txt ./ rm -rf sources # Clone CosaVostra's project echo echo -e "${BOLD_STYLE}${COLOR_INFO}> Cloning CosaVostra's repository...${RESET_STYLE}" mkdir -p sources cd sources if ! git clone --recursive ssh://git@gitlab.cosavostra.com:8364/cosavostra/richemont-media-innovation-lab.git ./ then echo -e "${BOLD_STYLE}${COLOR_FAILURE}Un problème est survenu. Arrêt.${RESET_STYLE}" exit fi LATEST_COMMIT_TITLE=$(git show -s --format=%s) TAG_NAME=$(date "+%Y.%m.%d.%H%M%S") # Install WordPress if [ -f ".wordpress-version" ] && [[ $(cat ".wordpress-version" | tr -d '[:space:]') != "" ]]; then WORDPRESS_VERSION=$(cat .wordpress-version | tr -d '[:space:]') else WORDPRESS_VERSION="6.3" fi # Remove ".0" from version if [[ ${WORDPRESS_VERSION} == *".0" ]]; then WORDPRESS_VERSION=${WORDPRESS_VERSION::-2} fi echo echo -e "${BOLD_STYLE}${COLOR_INFO}> Installing WordPress ${WORDPRESS_VERSION}${RESET_STYLE}" if [ -x "$(command -v wget)" ]; then if ! wget --show-progress https://fr.wordpress.org/wordpress-${WORDPRESS_VERSION}-fr_FR.zip --output-document wordpress.zip then echo -e "${BOLD_STYLE}${COLOR_FAILURE}Un problème est survenu. Arrêt.${RESET_STYLE}" exit fi else if ! curl --fail https://fr.wordpress.org/wordpress-${WORDPRESS_VERSION}-fr_FR.zip -L -o wordpress.zip then echo -e "${BOLD_STYLE}${COLOR_FAILURE}Un problème est survenu. Arrêt.${RESET_STYLE}" exit fi fi unzip -qq wordpress.zip rm wordpress.zip rsync -a wordpress/ ./ rm -rf .git/ .gitignore .gitlab-ci.yml .gitmodules .php-version .wordpress-version rm -rf wordpress/ rm -rf wp-content/plugins/akismet/ wp-content/plugins/hello.php # rm -rf wp-content/themes/twentytwentyone* # rm -rf wp-content/themes/twentytwentytwo* # rm -rf wp-content/themes/twenty* rm -rf README.md wp-config-sample.php # Push to Richemont's remote cd $FOLDER mv wp-config.php sources/ mv .htaccess sources/ mv robots.txt sources/ git add . git commit -m "Automatic push from CosaVostra's GitLab" -m "${LATEST_COMMIT_TITLE}" git tag $TAG_NAME git push --atomic origin master $TAG_NAME # Cleaning # rm -rf $FOLDER || echo "" echo echo -e "${BOLD_STYLE}${COLOR_SUCCESS}> OK${RESET_STYLE}"