Skip to content

Instantly share code, notes, and snippets.

@opi
Created March 9, 2020 09:32
Show Gist options
  • Save opi/01dd110ece64bef3826058fe2da4f528 to your computer and use it in GitHub Desktop.
Save opi/01dd110ece64bef3826058fe2da4f528 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 views --fields=title --format=list)
MODULE_VERSION=$(drush pm-info views --fields=version --format=list)
MODULE_PATH=$(drush pm-info views --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