Automatically deploy Middleman with Codeship to a VPS
$2.50 for a 512MB RAM VPS got me leaving Digital Ocean for Vultr. That’s more than enough for my small amount of Middleman-made static files, with Cloudflare sitting in front serving most of the traffic through their CDN.
While moving to my new home I realised that I could share how I deploy this thing.
▶︎ Have a repo. Here’s mine.
▶︎ Create a user on your VPS for Codeship. Don’t use root.
▶︎ Connect with your SCM (they support GitHub, Bitbucket and GitLab).
▶︎ Pick your repo and branch.
▶︎ Under “Configure your tests”, pick “I want to create my own custom commands” and enter this:
1 2 3 4 rvm use 2.3.1 --install npm install gulp install gulp build
Please peek inside my gulpfile.js to see what’s going on here.
▶︎ Carry on to the “Deployment Pipelines” settings. Pick “Custom Script” and enter your modified version of this:
1 rsync -avz -e "ssh" ./build/ [email protected]_ip_address:/var/www/example.com/html --delete-before
▶︎ Almost there! Now add the SSH public key for that Codeship project to your user so it can access your VPS. You’ll find it under “Settings > General”.
If you need help setting up the VPS I recommend these great guides from Digital Ocean: