Skip to content

Instantly share code, notes, and snippets.

@jamesfacts jamesfacts/deploy
Created Apr 11, 2019

Embed
What would you like to do?
if [ "production" == "${CI_ENVIRONMENT_NAME}" ]; then
FOLDER=/nas/content/live
WPE_INSTALL=YOURINSTALLNAME
elif [ "staging" == "${CI_ENVIRONMENT_NAME}" ]; then
FOLDER=/nas/content/staging
WPE_INSTALL=YOURINSTALLNAME
else
FOLDER=/nas/content/development
WPE_INSTALL=YOURINSTALLNAME
fi
#We now have three different site "environments", all of which are production
RENV=git@git.wpengine.com:production/${WPE_INSTALL}.git
# Forget the current repo
#####################################################################
rm -rf .git
rm -rf .gitignore
# Make a theme folder
mkdir $THEME_NAME
shopt -s extglob
mv !(${THEME_NAME}) ${THEME_NAME}
mv .editorconfig ${THEME_NAME}/.editorconfig
mv .eslintrc ${THEME_NAME}/.eslintrc
# build a WP install / dir structure EXACTLY like WPE from root
#####################################################################
mkdir -p $FOLDER
mv .gitignoredeploy $FOLDER/.gitignore
mv $THEME_NAME $FOLDER
# activate WP install
#####################################################################
cd $FOLDER
wp --allow-root core download --version=4.9.10
wp --allow-root core config --dbname=wordpress --dbuser=root --dbpass=wordpress --dbhost=mysql
wp --allow-root core install --url=${WPE_INSTALL}.dev --title=${WPE_INSTALL} --admin_user=wordpress --admin_email=${WPE_INSTALL}@${WPE_INSTALL}.com --skip-email
# install theme directory
mv $THEME_NAME wp-content/themes
# Git config while still at WP root
#####################################################################
git config --global user.email "${WPE_INSTALL}@${WPE_INSTALL}.com"
git config --global user.name "${WPE_INSTALL}"
git init
git remote add origin git@git.wpengine.com:${WPE_ENVIRONMENT}/${WPE_INSTALL}.git
# build theme
#####################################################################
cd wp-content/themes/${THEME_NAME}
composer install --no-ansi --no-dev --no-interaction --optimize-autoloader --no-progress
npm install
npm run build:production
cd ../../../
# build blade templates -- I find I have to do this twice
# the first build throws this error: 'Warning: Some code is trying to do a URL redirect.'
#####################################################################
wp --allow-root theme activate ${THEME_NAME}
wp --allow-root blade compile
wp --allow-root blade compile
# push
#####################################################################
git add .
git status
git ls-tree -r master --name-only
git commit -m "Deployment Commit"
git push origin master --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.