Skip to content

Instantly share code, notes, and snippets.

@jamesfacts
Last active September 26, 2017 22:09
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 jamesfacts/2a3a9ba12a2d504d22d5122d7bc464fa to your computer and use it in GitHub Desktop.
Save jamesfacts/2a3a9ba12a2d504d22d5122d7bc464fa to your computer and use it in GitHub Desktop.
Codeship CI script for Sage + WPE, with hashed Blade templates
# ssh git@git.wpengine.com info
# get around restriction on shallow pushes by WP Engine
git filter-branch -- --all
git checkout master
git config --global user.name "${CI_COMMITTER_NAME}"
git config --global user.email "${CI_COMMITTER_EMAIL}"
# Combine remote git servers
git remote add servers $WPE_SERVERS
git remote set-url --add --push servers $WPE_SERVERS
# install WP-CLI
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar ~/
# install blade generate
php -d memory_limit=512M ~/wp-cli.phar --allow-root package install git@github.com:alwaysblank/blade-generate.git
# Move repo files to a named folder
mkdir $FOLDERNAME
shopt -s extglob
rm .gitignore
mv .codeshipignore .gitignore
mv !($FOLDERNAME) $FOLDERNAME
# download copy of wp core - wp install is needed only in order to cache templates
php -d memory_limit=512M ~/wp-cli.phar core download
# db, user, and pw are all env vars provided by codeship
php -d memory_limit=512M ~/wp-cli.phar config create --dbname=test --dbuser=root --dbpass=test
php -d memory_limit=512M ~/wp-cli.phar core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword --admin_email=info@example.com
# install modules
mv $FOLDERNAME wp-content/themes
cd wp-content/themes/$FOLDERNAME
phpenv local 5.6.31
composer install --prefer-dist --no-interaction
nvm use stable
npm install -g yarn
# Build
yarn
yarn run build:production
# activate theme and build blade templates
cd ../../..
phpenv local 5.6.31
php -d memory_limit=512M ~/wp-cli.phar --allow-root theme activate $FOLDERNAME
php -d memory_limit=512M ~/wp-cli.phar --allow-root blade compile
# for some reason this command fails the first time, runs ok the second
php -d memory_limit=512M ~/wp-cli.phar --allow-root blade compile
# Deploy
git add --all :/
git commit -m "DEPLOYMENT"
git push servers HEAD:master --force
# If this is the first time you're running the deployment, you might try this next line instead in case you get a missing branch error:
# git push servers HEAD:refs/heads/master --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment