Fix plugin installation when working from a push instead of a pull request. (https://github.com/woocommerce/woocommerce-admin/pull/2950)

This commit is contained in:
Jeff Stieler 2019-09-24 08:59:38 -07:00 committed by GitHub
parent 0be875d898
commit 8b77fe144e
1 changed files with 7 additions and 10 deletions

View File

@ -159,16 +159,8 @@ install_deps() {
# Script Variables # Script Variables
WP_SITE_URL="http://local.wordpress.test" WP_SITE_URL="http://local.wordpress.test"
BRANCH=$TRAVIS_BRANCH
REPO=$TRAVIS_REPO_SLUG
WORKING_DIR="$PWD" WORKING_DIR="$PWD"
if [ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then
BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
REPO=$TRAVIS_PULL_REQUEST_SLUG
fi
# Set up WordPress using wp-cli # Set up WordPress using wp-cli
mkdir -p "$WP_CORE_DIR" mkdir -p "$WP_CORE_DIR"
cd "$WP_CORE_DIR" cd "$WP_CORE_DIR"
@ -189,9 +181,14 @@ install_deps() {
cd "$WP_CORE_DIR" cd "$WP_CORE_DIR"
php wp-cli.phar plugin activate woocommerce php wp-cli.phar plugin activate woocommerce
if [ ! -z "$TRAVIS_PULL_REQUEST_BRANCH" ]; then
BRANCH="$(sed 's/#/%23/' <<<$BRANCH)"
# Install woocommerce-admin, the correct branch, if running from Travis CI. # Install woocommerce-admin, the correct branch, if running from Travis CI.
if [ "${TRAVIS}" = "true" ]; then
# Default to the pull request branch if this is a PR, otherwise pushed branch.
BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
# Default to the pull request repo if this is a PR, otherwise default.
REPO=${TRAVIS_PULL_REQUEST_SLUG:-$TRAVIS_REPO_SLUG}
BRANCH="$(sed 's/#/%23/' <<<$BRANCH)"
# Install with WP CLI.
php wp-cli.phar plugin install https://github.com/$REPO/archive/$BRANCH.zip --activate php wp-cli.phar plugin install https://github.com/$REPO/archive/$BRANCH.zip --activate
fi fi