Skip to content

Instantly share code, notes, and snippets.

@khromov
Created June 8, 2016 07:28
Show Gist options
  • Save khromov/ef51f6c1c229ea8be288cf6a21fda770 to your computer and use it in GitHub Desktop.
Save khromov/ef51f6c1c229ea8be288cf6a21fda770 to your computer and use it in GitHub Desktop.
Deploy WordPress with Deployer on EasyEngine
<?php
require 'recipe/common.php';
// Set configurations
set('repository', 'ssh://[email protected]:22/user/repo.git');
set('shared_files', ['public/wp-config.php']);
set('shared_dirs', ['public/wp-content/uploads']);
set('writable_dirs', []);
set('keep_releases', 10);
set('composer_command', 'composer');
//Defaults for all servers
env('timezone', 'Europe/Stockholm');
env('branch', 'master');
// Configure servers
server('production', 'server.com')
->user('root')
->identityFile()
->forwardAgent()
->env('deploy_path', '/var/www/site/deployer');
/**
* Chown files to correct user
*/
task('deploy:chown', function () {
run('chown -R www-data:www-data ' . env('deploy_path'));
});
/**
* Restart php-fpm
*/
task('deploy:restart-php', function () {
run('ee stack restart --php7');
});
/**
* Restart Memcached
*/
task('deploy:restart-memcached', function () {
run('service memcached restart');
});
/**
* Write current Git commit hash to version.txt of current release
*/
task('deploy:write_version', function () {
cd(env('deploy_path') . '/current/public/');
run('git rev-parse HEAD > version.txt');
});
/**
* Display current Git commit hash
*/
task('info:version', function() {
cd(env('deploy_path') . '/current');
$version = run('git rev-parse HEAD')->getOutput();
write("Currently deployed commit: <info>$version</info>");
});
/**
* Main task
*/
task('deploy', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:writable',
'deploy:symlink',
'deploy:vendors',
'deploy:write_version',
'deploy:chown',
'deploy:restart-php',
'deploy:restart-memcached',
'cleanup',
'info:version'
])->desc('Deploy your project');
after('deploy', 'success');
@khromov
Copy link
Author

khromov commented Jun 8, 2016

Deploy
./dep deploy production

See released version
./dep info:version production

@renatonascalves
Copy link

Really usefull!

You should add this recipe here: https://github.com/deployphp/recipes

@hgati
Copy link

hgati commented Jan 27, 2018

great~ this is a recipe itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment