Deploy your code using version control and continuous integration
PRODUCTION-READY WORDPRESS
• Presenter
• Front End Developer
• Senior Sales Engineer - WP Engine
• Music Technology
Edmund Turbin
@spicecadet
Production
Ready Wordpress
Contents
The Problem
The Solution
The Script
Demonstration
Learnings
Deployment, version control and continuous
integration
The Problem
Deploy your
site
• Manage the way code is deployed
• Automate repetitive tasks for devs, admins when changes
go live
• Make it easy to use best practices
• Allow for flexibility, multiple deploy processes, safe testing
The Solution
The Solution
• Develop Locally
• Distributed Version Control
• Don’t keep plugins and WP core in repository
• Deploy to testing environment prior to production
• Automate build and testing
Continuous
Integration
• Multiple developers share code
• Several pushes per day
• Each push verified by automated build
• Avoids “integration hell”
• Teams can detect problems early
Workflow
• Local Development
• Central Version Control
• Continuous Integration Pipelines
• Build Script
• Dependencies
• Push to server
Version
Control
Repo
Workflow
Install
&
Build
Repo Deps Push
Deployment
Initial Setup
Setup
Clone
Repo
Install
Apps
Configure
Env
Build
Build
Build ConcatUglify
Compile
Sass/Less
JS Lint
Dependencies
Dependencies PluginsWPackagist
Testing
Test
Automated
Testing
Tools
Theme
Local
Development
Build
Collaboration/
VCS
Dependencies
Continuous
Integration Tool
Continuous
Integration Tool
Continuous
Integration Tool
Continuous
Integration Tool
Continuous
Integration Tool
Automated
Testing
Automated
Testing
The Script
#	Set	Constants	
INSTALL="edmund"	
EMAIL="edmund.turbin@wpengine.com"	
ENVIRONMENT=“production"	
#	Use	Node	8.7.0	
nvm	use	stable	
#	Disable	Xdebug	
rm	-f	/home/rof/.phpenv/versions/$(phpenv	version-name)/etc/conf.d/
xdebug.ini
#	Codeship	project	root	is	the	~/clone	directory	
cd	~/clone	
#	Set	production	remote	and	config	
git	config	--global	user.name	"Codeship	Deploy"	
git	config	--global	user.email	"$EMAIL"	
git	remote	add	$ENVIRONMENT	git@git.wpengine.com:$ENVIRONMENT/
$INSTALL.git	
#	Codeship	initially	runs	a	shallow	fetch.	This	allows	us	to	fetch	
origin	and	get	all	file	revisions	
git	fetch	--unshallow	||	true	
git	fetch	origin	"+refs/heads/*:refs/remotes/origin/*"
#	Run	Composer	to	install	dependencies	
cd	wp-content/themes/sage	
composer	install	--prefer-source	—no-interaction	
#	Run	build	tasks	
npm	install	
bower	install	
gulp	—production
#	Remove	unnecessary	files	
rm	~/clone/.gitignore	
#	Git	Commit	and	Push	
git	add	--all	
git	commit	-m	"Codeship	Deployment"	
git	push	$ENVIRONMENT	HEAD:master	--force
#	Assertible	Tests	
curl	-u	DLI7uFTdkcpfcXdQ:	"https://assertible.com/deployments"	-d'{	
				"service":	"43994ec7-41e0-4d7f-9155-6945816333f1",	
				"environmentName":	"production",	
				"version":	"v1"	
}'
DemonstratioN
Learnings
Codeship
• Uses a virtual machine at time of deploy
• Has many common binaries installed, possible to install more
• Caches NPM packages
• Can be used in Debug mode which allows you to SSH into the
virtual machine and run commands until happy
Git Integration
• Understanding how to move files from Codeship was
difficult
• A few different attempts to make this happen
• Possible to use FTP, but Git is more streamlined and quicker
• git push — force option important - not all files in the repo
are needed in production
Build
• Gulp, Grunt, Webpack.js, etc. can all be run during
deployment
• Local development can use it’s own build script
• Possible to use different tasks or build scripts for each
branch
• Allows for release management - deploy different branches
to their own server environments (stage, test, production)
Next Steps
• Do more testing with Assertible 😁
• Remove all source files and unnecessary files like readme 😎
• Create automated rollback functionality, look at symlinks 😵
• Wishlist: Visual Regression Testing with NPM/Wraith, Backstop.js 👊
Reference
Team Collaboration with Github
7 Easy Steps to Continuous Deployment
Optimize Local Development
Codeship Deployment Script
Post Deployment Smoke-Testing with Assertible
Questions
@spicecadet
edmund.turbin@wpengine.com

Production Ready WordPress #WPLDN