<?php

namespace Deployer;

require_once './vendor/autoload.php';

require 'recipe/common.php';
require 'recipe/rsync.php';

set('application', 'storybook');
set('git_tty', false);
set('default_timeout', 960);
set('allow_anonymous_stats', false);

$hostNames = [
    'storybook' => '82.196.10.160',
];

// Storybook
host('storybook-matrix.gigmedia.com')
    ->hostname($hostNames['storybook'])
    ->stage('storybook')
    ->set('deploy_path', '/var/www/storybook-sports.gigmedia.com')
    ->set('rsync_src', __DIR__)
    ->set('rsync_dest', '{{release_path}}');

desc('Deploy your project');
task('deploy', [
    'deploy:info',
    'deploy:prepare',
    'deploy:lock',
    'deploy:release',
    'rsync',
    'deploy:writable',
    'deploy:symlink',
    'deploy:unlock',
    'cleanup',
]);

set('rsync', [
    'exclude' => [],
    'exclude-file' => false,
    'include' => [],
    'include-file' => realpath('scripts/rsync.filter.txt'),
    'filter' => [],
    'filter-file' => false,
    'filter-perdir' => false,
    'flags' => 'rz', // Recursive, with compress
    'options' => ['delete'],
    'timeout' => 60
]);

after('deploy', 'success');

after('deploy:failed', 'deploy:unlock');
