Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# Find security updates
MODULE_LIST_FILENAME=module_list
rm $MODULE_LIST_FILENAME #This is just for local dev testing
touch $MODULE_LIST_FILENAME
terminus auth:login
terminus drush prepme.live -- ups --security-only --pipe > $MODULE_LIST_FILENAME
# Check if there are things to update
FILE_SIZE=$(ls -la $MODULE_LIST_FILENAME | awk '{ print $5}')
echo $FILE_SIZE
if [ "$FILE_SIZE" -gt "0" ]; then
# Add new line to file for looping
echo "" >> $MODULE_LIST_FILENAME
# Build PR details
PR_TITLE="Automated security update"
PR_BODY="Module(s) updated:"
# Update PR body
filename=$MODULE_LIST_FILENAME
n=1
while read line; do
# reading each line
PR_BODY="${PR_BODY}\n$line"
done < $filename
PR_BODY="${PR_BODY}\n\nThis PR was automatically created by CircleCI."
echo $PR_BODY
# Update modules for composer
sed -i -e 's/^/composer update drupal\//' $MODULE_LIST_FILENAME
# Composer update.
filename=$MODULE_LIST_FILENAME
n=1
while read line; do
# reading each line
eval $line
done < $filename
# Commit composer changes
#git config user.email "code@kanopistudios.com"
#git config user.name "KanopiCode"
#git checkout -b security_fixes
#git commit -m "Update packages for security releases" composer.json composer.lock
#git push security_fixes
# Need git hub api stuff
hub api repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls --field body=@${PR_BODY} title=@${PR_TITLE} head=security_fixes base=master
# need slack notification
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment