Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACSF Cloud Hooks / Factory Hooks Enhancements #2685

Merged
merged 2 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 26 additions & 10 deletions scripts/cloud-hooks/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 25 additions & 0 deletions settings/acsf/db-update/db-update.sh
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is artifact:update:drupal:all-sites available in blt 8.9.x? I don't believe it is.


$deployupdate
23 changes: 23 additions & 0 deletions settings/acsf/post-install/post-install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

/**
* @file
* Factory Hook: post-install.
*
* This hook enables you to execute PHP after a new website is created
* in your subscription. Unlike most API-based hooks, this hook does not
* take arguments, but instead executes the PHP code it is provided.
*
* This is used so that an ACSF site install will match a local BLT site
* install. After a local site install, the update functions are run.
*
*/

$site = $_ENV['AH_SITE_GROUP'];
$env = $_ENV['AH_SITE_ENVIRONMENT'];

// The public domain name of the website.
// Run updates against requested domain rather than acsf primary domain.
$domain = $_SERVER['HTTP_HOST'];

exec("/mnt/www/html/$target_env/vendor/acquia/blt/bin/blt artifact:update:drupal --define environment=$env --define drush.uri=$domain --verbose --yes");
12 changes: 12 additions & 0 deletions settings/acsf/post-settings-php/includes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

/**
* @file
* Example implementation of ACSF post-settings-php hook.
*
* @see https://docs.acquia.com/site-factory/tiers/paas/workflow/hooks
*/

// Set config directories to default location.
$config_directories['vcs'] = '../config/default';
$config_directories['sync'] = '../config/default';
14 changes: 14 additions & 0 deletions settings/acsf/post-theme-deploy/clear-twig-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
# Clears TWIG cache for a site after a theme deploy. Executes via drush alias.
# See https://docs.acquia.com/site-factory/theme/external#refresh.
# $1 = The hosting site group.
# $2 = The hosting environment.
# $5 = The site domain.
site="$1"
env="$2"

# local drush executable:
repo="/var/www/html/$site.$env"

cd $repo
drush @$1.$2 --uri=$5 ev '\Drupal\Core\PhpStorage\PhpStorageFactory::get("twig")->deleteAll();'