Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jameswilson/0ad4f453eb2951319779a31ad1c0809f to your computer and use it in GitHub Desktop.
Save jameswilson/0ad4f453eb2951319779a31ad1c0809f to your computer and use it in GitHub Desktop.
Acquia Cloud Hooks environment-indicator.sh
#!/bin/bash
#hooks/common/post-code-deploy/environment-indicator.sh
set -e
site="$1"
target_env="$2"
source_branch="$3"
docroot="/var/www/html/$site.$target_env/docroot"
DRUSH_CMD="/var/www/html/$site.$target_env/vendor/bin/drush --root=$docroot"
RELEASE_FILE="$HOME/.$site.$target_env.current_release.txt"
BRANCHNAME_OR_TAG=$(echo "$source_branch" | sed -e "s/tags\//v/" | sed -e "s/pipelines-build-//")
$DRUSH_CMD @$site.$target_env sset environment_indicator.current_release $BRANCHNAME_OR_TAG
printf "Drupal environment indicator release set to '$BRANCHNAME_OR_TAG' by post-code-deploy hook.\n"
# Store the current release outside the database, so we can restore the correct
# value after a db copy (see post-db-copy/environment-indicator.sh)
echo $BRANCHNAME_OR_TAG >| $RELEASE_FILE
#!/bin/bash
# hooks/common/post-code-update/environment-indicator.sh
set -e
site="$1"
target_env="$2"
source_branch="$3"
docroot="/var/www/html/$site.$target_env/docroot"
DRUSH_CMD="/var/www/html/$site.$target_env/vendor/bin/drush --root=$docroot"
RELEASE_FILE="$HOME/.$site.$target_env.current_release.txt"
BRANCHNAME_OR_TAG=$(echo "$source_branch" | sed -e "s/tags\//v/" | sed -e "s/pipelines-build-//")
$DRUSH_CMD @$site.$target_env sset environment_indicator.current_release $BRANCHNAME_OR_TAG
printf "Drupal environment indicator release set to '$BRANCHNAME_OR_TAG' by post-code-update hook.\n"
# Store the current release outside the database, so we can restore the correct
# value after a db copy (see post-db-copy/environment-indicator.sh)
echo $BRANCHNAME_OR_TAG >| $RELEASE_FILE
#!/bin/bash
#hooks/common/post-db-copy/environment-indicator.sh
set -e
site="$1"
target_env="$2"
docroot="/var/www/html/$site.$target_env/docroot"
DRUSH_CMD="/var/www/html/$site.$target_env/vendor/bin/drush --root=$docroot"
RELEASE_FILE="$HOME/.$site.$target_env.current_release.txt"
BRANCHNAME_OR_TAG=$(cat $RELEASE_FILE 2>/dev/null)
$DRUSH_CMD @$site.$target_env sset environment_indicator.current_release $BRANCHNAME_OR_TAG
printf "Drupal environment indicator release set to '$BRANCHNAME_OR_TAG' by post-db-copy hook.\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment