Skip to content

Instantly share code, notes, and snippets.

@paulsheldrake
Last active September 17, 2020 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulsheldrake/efc3a7f8aed0cbb8184cfff13987005b to your computer and use it in GitHub Desktop.
Save paulsheldrake/efc3a7f8aed0cbb8184cfff13987005b to your computer and use it in GitHub Desktop.
#!/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