Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utils/auto-composer-update.sh for updating on cron #3994

Merged
merged 1 commit into from Apr 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 50 additions & 0 deletions utils/auto-composer-update.sh
@@ -0,0 +1,50 @@
#!/bin/bash

###
# Runs composer update, commits changes to a new branch,
# and creates a pull request.
#
# Requires git, composer, and hub
###

date

if [ -z "$WP_CLI_DIR" ]; then
echo 'Please set $WP_CLI_DIR'
exit 1
fi

set -ex

cd $WP_CLI_DIR

# Reset WP-CLI directory to baseline
git checkout -f master
git pull origin master
composer install --no-dev
# Run composer update and capture to untracked log file
composer update --no-progress --no-dev --no-interaction |& tee vendor/update.log
UPDATE=$(cat vendor/update.log | col -b)

# We only care to proceed when there are changes
if [ -z "$(git status -s)" ]; then
echo 'No updates available'
exit 0;
fi

# Create a dated branch and commit the changes
DATE=$(date +%Y-%m-%d)
BRANCH="update-deps-$DATE"
git branch -f $BRANCH master
git checkout $BRANCH
git add .
MESSAGE="Update Composer dependencies ($DATE)

\`\`\`
$UPDATE
\`\`\`"
git commit -m "$MESSAGE"

# Push and pull request
git push origin $BRANCH
hub pull-request -m "$MESSAGE"