From 5c995a21a5bdac8cbd97f794881801444b4ef4ab Mon Sep 17 00:00:00 2001 From: vyasamit2007 Date: Tue, 27 Mar 2018 18:32:58 +0530 Subject: [PATCH] ACSF Cloud Hooks / Factory Hooks Enhancements --- scripts/cloud-hooks/functions.sh | 36 +++++++++++++------ .../post-code-deploy/post-code-deploy.sh | 4 +++ settings/acsf/db-update/db-update.sh | 25 +++++++++++++ settings/acsf/post-install/post-install.php | 23 ++++++++++++ settings/acsf/post-settings-php/includes.php | 12 +++++++ .../post-theme-deploy/clear-twig-cache.sh | 14 ++++++++ 6 files changed, 104 insertions(+), 10 deletions(-) create mode 100755 settings/acsf/db-update/db-update.sh create mode 100755 settings/acsf/post-install/post-install.php create mode 100644 settings/acsf/post-settings-php/includes.php create mode 100644 settings/acsf/post-theme-deploy/clear-twig-cache.sh diff --git a/scripts/cloud-hooks/functions.sh b/scripts/cloud-hooks/functions.sh index d1ea049c5..4182d19b3 100644 --- a/scripts/cloud-hooks/functions.sh +++ b/scripts/cloud-hooks/functions.sh @@ -7,16 +7,14 @@ drush_alias=${site}'.'${target_env} deploy_updates() { - case $target_env in - 01dev|01test|01live) - acsf_deploy - ;; - 01devup|01testup|01update) - ;; - *) - ace_deploy - ;; - esac + if [[ $target_env =~ [0-9][1-9](dev|test) ]]; then + acsf_deploy + elif [[ $target_env =~ [0-9][1-9](devup|testup|update)|[0-9][1-9](live)|ode[0-9]* ]]; then + deploy_install + else + ace_deploy + fi + } acsf_deploy() { @@ -71,6 +69,24 @@ ace_deploy() { echo "Finished updates for environment: $target_env" } +deploy_sync() { + + echo "Running sync refresh for environment: $target_env" + + # Prep for BLT commands. + repo_root="/var/www/html/$site.$target_env" + export PATH=$repo_root/vendor/bin:$PATH + cd $repo_root + + blt deploy:sync:refresh --define environment=$target_env -v -y + if [ $? -ne 0 ]; then + echo "Sync errored." + exit 1 + fi + + echo "Finished sync for environment: $target_env" +} + deploy_install() { echo "Installing site for environment: $target_env" diff --git a/scripts/cloud-hooks/hooks/common/post-code-deploy/post-code-deploy.sh b/scripts/cloud-hooks/hooks/common/post-code-deploy/post-code-deploy.sh index 6b4492888..20027a845 100755 --- a/scripts/cloud-hooks/hooks/common/post-code-deploy/post-code-deploy.sh +++ b/scripts/cloud-hooks/hooks/common/post-code-deploy/post-code-deploy.sh @@ -20,9 +20,13 @@ repo_url="$5" repo_type="$6" +acsf_file="/mnt/files/$site.$target_env/files-private/sites.json" +if [ ! -f $acsf_file ]; then . /var/www/html/$site.$target_env/vendor/acquia/blt/scripts/cloud-hooks/functions.sh deploy_updates +fi # Send notifications to Slack, if configured. See readme/deploy.md for setup instructions. . `dirname $0`/../slack.sh + set +v diff --git a/settings/acsf/db-update/db-update.sh b/settings/acsf/db-update/db-update.sh new file mode 100755 index 000000000..b37ac3492 --- /dev/null +++ b/settings/acsf/db-update/db-update.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# Factory Hook: db-update +# +# The existence of one or more executable files in the +# /factory-hooks/db-update directory will prompt them to be run *instead of* the +# regular database update (drush updatedb) command. So that update command will +# normally be part of the commands executed below. +# +# Usage: post-code-deploy site env db-role domain custom-arg +# Map the script inputs to convenient names. +# Acquia hosting site / environment names +site="$1" +env="$2" +# database role. (Not expected to be needed in most hook scripts.) +db_role="$3" +# The public domain name of the website. +domain="$4" + +# BLT executable: +blt="/var/www/html/$site.$env/vendor/acquia/blt/bin/blt" + +deployupdate="$blt artifact:update:drupal:all-sites --define environment=$env --define drush.uri=$domain --verbose --yes" + +$deployupdate diff --git a/settings/acsf/post-install/post-install.php b/settings/acsf/post-install/post-install.php new file mode 100755 index 000000000..79f9f0427 --- /dev/null +++ b/settings/acsf/post-install/post-install.php @@ -0,0 +1,23 @@ +deleteAll();'