Skip to content

Instantly share code, notes, and snippets.

@toabr
Last active August 11, 2021 10:17
Show Gist options
  • Save toabr/2a5c1cface37169d13c8338d7eb5a4e1 to your computer and use it in GitHub Desktop.
Save toabr/2a5c1cface37169d13c8338d7eb5a4e1 to your computer and use it in GitHub Desktop.
Drupal 8 deployment script via git (bare repository)
#!/bin/bash
# @file
# deploy Production the Environment
SOURCE="@self"
TARGET="@live"
FORMAT='\e[1;33m#'
RESET='\033[0m' # No Color
# prompt user for commit message
read -p "$(echo $FORMAT "Commit Message: "$RESET)" MESSAGE
# check for empty commit message
if [ "$MESSAGE" != "" ]; then
## export latest configs
drush $SOURCE config:export
## deploy the latest code
git add .
git commit -a -m "$MESSAGE"
git push live master
## install packages
drush $TARGET ssh composer install --no-dev
drush $TARGET updatedb
## import uploaded configs
drush $TARGET -y state:set system.maintenance_mode 1
drush $TARGET config:import
drush $TARGET cache:rebuild
drush $TARGET -y state:set system.maintenance_mode 0
else
echo "You must provide a commit message!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment