Skip to content

Instantly share code, notes, and snippets.

@opi
Created September 14, 2020 08:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opi/160a38319417a6e7957e20d798321161 to your computer and use it in GitHub Desktop.
Save opi/160a38319417a6e7957e20d798321161 to your computer and use it in GitHub Desktop.
Drupal 7 Contrib update
#!/bin/bash
function greenecho {
echo "" && echo -e "\e[30;48;5;82m ✔ $1 \e[0m"
}
function orangeecho {
echo "" && echo -e "\e[30;48;5;208m ⚠ $1 \e[0m"
}
greenecho "Here we are: "$(pwd)
#CONTRIB_NAME=$1
# Update sources
greenecho "Update sources ..."
git pull --quiet origin master
greenecho "Check for outdated modules"
MODULE_LIST=$(drush pm-updatecode --no-core -n --pipe)
# drush pm-updatecode --no-core -n --pipe > $MODULE_LIST 2>/dev/null
if [ -n "$MODULE_LIST" ] ; then
# greenecho "Modules to update: $MODULE_LIST"
while read MODULE; do
greenecho "Updating $MODULE..."
drush up --quiet -y $MODULE > /dev/null
MODULE_NAME=$(drush pm-info ${MODULE} --fields=title --format=list)
MODULE_VERSION=$(drush pm-info ${MODULE} --fields=version --format=list)
MODULE_PATH=$(drush pm-info ${MODULE} --fields=path --format=list)
git add --all $MODULE_PATH > /dev/null
git commit -m "[up] $MODULE_NAME $MODULE_VERSION"
done < <(printf '%s\n' "$MODULE_LIST")
else
orangeecho "Nothing to update"
fi
greenecho "Push updated sources"
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment