Skip to content

Instantly share code, notes, and snippets.

@mneuhaus
Created October 21, 2015 07:20
Show Gist options
  • Save mneuhaus/b997071da08c21d476e3 to your computer and use it in GitHub Desktop.
Save mneuhaus/b997071da08c21d476e3 to your computer and use it in GitHub Desktop.
Basic test for deploying a flow application through deployer
<?php
// All Deployer recipes are based on `recipe/common.php`.
require 'recipe/common.php';
// require 'rsync.php'; // optionally used from https://github.com/deployphp/recipes
require 'flow.php';
env('php_binary', 'php_cli');
set('shared_dirs', [
'Data/Logs',
'Data/Persistent',
'Configuration/Production',
'Configuration/Development'
]);
set('writable_dirs', [
'Data/Logs',
'Data/Persistent',
'Configuration/Production',
'Configuration/Development'
]);
/**
* Main task
*/
task('deploy', [
'deploy:prepare',
'deploy:release',
// checkout git remotely and do a composer install
// 'deploy:update_code',
//'deploy:vendors',
// or rsync this current directory to the remote
'rsync',
'deploy:shared',
'flow:migrate',
'flow:publishresources',
'deploy:symlink',
'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');
server('dev', 'foo.bar.com', 22)
->user('foo')
->identityFile()
->stage('production')
->env('deploy_path', '/html/bar/');
set('repository', 'ssh://foo/bar.git');
<?php
/* (c) Anton Medvedev <anton@elfet.ru>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
env('php_binary', 'php');
/**
* Execute flow migrations
*/
task('flow:migrate', function () {
run("{{php_binary}} {{release_path}}/flow doctrine:migrate");
})->desc('execute any pending migration');
/**
* Execute flow publish resources
*/
task('flow:publishresources', function () {
run("{{php_binary}} {{release_path}}/flow typo3.flow:resource:publish");
})->desc('publish flow resources');
/**
* Create symlink to last release using relative path
* wtf? -> well, mittwald doesn't work with absolute symlinks, so i had
* to implement this workaround to get it working :)
*/
task('deploy:symlink', function () {
env('relative_release_path', str_replace(env('deploy_path'), '.', env('release_path')));
run("cd {{deploy_path}} && ln -sfn {{relative_release_path}} current"); // Atomic override symlink.
run("cd {{deploy_path}} && rm release"); // Remove release link.
})->desc('Creating symlink to release');
/**
* default rsync settings for flow
*/
set('rsync', [
'exclude' => [
'.git',
'deploy.php',
'Build',
'Data'
],
'exclude-file' => false,
'include' => [],
'include-file' => false,
'filter' => [],
'filter-file' => false,
'filter-perdir' => false,
'flags' => 'rz',
'options' => ['delete'],
'timeout' => 600,
]);
env('rsync_src', getcwd());
env('rsync_dest','{{release_path}}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment