Created
December 4, 2020 08:20
-
-
Save opi/06c2f7a775266fd6b6f23dafcec6eac9 to your computer and use it in GitHub Desktop.
Automate Drupal7 contrib update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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|grep -v ^drupal) # |grep -v ^drupal because --no-core does not always works :( | |
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") | |
greenecho "Push updated sources" | |
git push origin master | |
else | |
orangeecho "Nothing to update" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment