Skip to content

Instantly share code, notes, and snippets.

@schikulski
Created May 5, 2014 19:55
Show Gist options
  • Save schikulski/11545921 to your computer and use it in GitHub Desktop.
Save schikulski/11545921 to your computer and use it in GitHub Desktop.
Mina WordPress deploy config
require 'mina/git' # Require mina/git
set :term_mode, nil # Bug in OS X that makes the password promp kinda fishy...
set :domain, 'example.com' # The web servers SSH domain
set :deploy_to, '/home/user/my-site' # Full path to where you want Mina to deploy
set :repository, 'https://[email protected]/USERNAME/REPOSITORY.git' # The git repository Mina shall use
set :branch, 'master' # What git branch Mina should get
set :user, 'username' # What username to connect with through SSH
set :current_path, 'www' # What file should be the current version. Probably 'www', 'public_html' or perhaps 'current'.
set :keep_releases, '5' # How many releases should Mina keep on the server
# Shared paths and files for all versions.
set :shared_paths, ['app/uploads', '.env', '.htaccess']
# The SETUP task - creating the necessary directories
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/shared/app/uploads"]
end
# The DEPLOY task, clone git repository and linking the shared paths
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone' # cloning repository
invoke :'deploy:link_shared_paths' # linking shared paths
invoke :'deploy:cleanup' # cleaning all releases, keeping x releases
end
end
# The ROLLBACK task - thanks Vinh Quốc Nguyễn! - http://code.tutsplus.com/articles/an-introduction-to-deploying-wordpress-with-mina--wp-34776
desc "Rollback to previous verison."
task :rollback => :environment do
queue %[echo "----> Start to rollback"]
queue %[if [ $(ls #{deploy_to}/releases | wc -l) -gt 1 ]; then echo "---->Relink to previos release" && unlink #{deploy_to}/current && ln -s #{deploy_to}/releases/"$(ls #{deploy_to}/releases | tail -2 | head -1)" #{deploy_to}/current && echo "Remove old releases" && rm -rf #{deploy_to}/releases/"$(ls #{deploy_to}/releases | tail -1)" && echo "$(ls #{deploy_to}/releases | tail -1)" > #{deploy_to}/last_version && echo "Done. Rollback to v$(cat #{deploy_to}/last_version)" ; else echo "No more release to rollback" ; fi]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment