Skip to content

Instantly share code, notes, and snippets.

@bjoerne2 bjoerne2/deploy.php

Created Dec 20, 2018
Embed
What would you like to do?
<?php
namespace Deployer;
use Exception;
require 'recipe/common.php';
// Project name
set('application', '<application>');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// Shared files/dirs between deploys
add('shared_files', ['.htaccess', 'wp-config.php']);
add('shared_dirs', ['wp-content/uploads']);
// Writable dirs by web server
add('writable_dirs', []);
set('allow_anonymous_stats', false);
// Hosts
host('<host>')
->user('<user>')
->set('deploy_path', '<deploy_path>');
task('deploy:update_code', function () {
$tmpfile_resource = tmpfile();
$tmpfile = stream_get_meta_data($tmpfile_resource)['uri'];
fclose($tmpfile_resource);
runLocally("git archive --format=zip -o $tmpfile HEAD");
run('mkdir -p {{deploy_path}}/tmp');
upload($tmpfile, '{{deploy_path}}/tmp/archive.zip');
run('unzip -d {{release_path}} {{deploy_path}}/tmp/archive.zip');
run('rm {{deploy_path}}/tmp/archive.zip');
});
task('deploy', [
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:writable',
'deploy:symlink',
'deploy:unlock',
'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.