Exemple #1
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Cleaning up files and/or directories');
task('deploy:clear_paths', function () {
    $paths = get('clear_paths');
    $sudo = get('clear_use_sudo') ? 'sudo' : '';
    foreach ($paths as $path) {
        run("{$sudo} rm -rf {{release_path}}/{$path}");
    }
});
Exemple #2
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Rollback to previous release');
task('rollback', function () {
    $releases = get('releases_list');
    if (isset($releases[1])) {
        $releaseDir = "{{deploy_path}}/releases/{$releases[1]}";
        // Symlink to old release.
        run("cd {{deploy_path}} && {{bin/symlink}} {$releaseDir} current");
        // Remove release
        run("rm -rf {{deploy_path}}/releases/{$releases[0]}");
        if (isVerbose()) {
            writeln("Rollback to `{$releases[1]}` release was successful.");
        }
    } else {
        writeln("<comment>No more releases you can revert to.</comment>");
    }
});
Exemple #3
0
        p(2);
    });
});
desc('bleem');
task('bleem', function () {
    p(0);
});
after('bleem:baz', function () {
    p(3);
});
desc('foo');
task('foo', function () {
    p(5);
});
desc('bar');
task('bar', function () {
    p(8);
});
task('foo', function () {
    p(6);
});
before('foo', function () {
    p(4);
});
after('foo', function () {
    p(7);
});
task('foo', 'bleem:baz');
desc('default');
task('default', 'foo');
task('default', 'bar');
Exemple #4
0
<?php

/* (c) David Jordan / CyberDuck <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Clearing Cloudflare Cache');
task('deploy:cloudflare', function () {
    $config = get('cloudflare', []);
    //validate config and set headers
    if (!empty($config['service_key'])) {
        $headers = ['X-Auth-User-Service-Key' => $config['service_key']];
    } elseif (!empty($config['email']) && !empty($config['api_key'])) {
        $headers = ['X-Auth-Key' => $config['api_key'], 'X-Auth-Email' => $config['email']];
    } else {
        throw new \RuntimeException("Set a service key or email / api key");
    }
    $headers['Content-Type'] = 'application/json';
    if (empty($config['domain'])) {
        throw new RuntimeException("Set a domain");
    }
    $makeRequest = function ($url, $opts = []) use($headers) {
        $ch = curl_init("https://api.cloudflare.com/client/v4/{$url}");
        foreach ($headers as $key => $value) {
            $parsedHeaders[] = "{$key}: {$value}";
        }
        curl_setopt_array($ch, [CURLOPT_HTTPHEADER => $parsedHeaders, CURLOPT_RETURNTRANSFER => true]);
        curl_setopt_array($ch, $opts);
Exemple #5
0
<?php

/* (c) Samuel Gordalina <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Notifying New Relic of deployment');
task('deploy:newrelic', function () {
    global $php_errormsg;
    $config = get('newrelic', array());
    if (!is_array($config) || !isset($config['license']) || !isset($config['app_name']) && !isset($config['application_id'])) {
        throw new \RuntimeException("<comment>Please configure new relic:</comment> <info>set('newrelic', array('license' => 'xad3...', 'application_id' => '12873'));</info>");
    }
    $git = array('user' => trim(runLocally('git config user.name')), 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'description' => trim(runLocally('git log -n 1 --format="%an: %s" | tr \'"\' "\'"')));
    $postdata = array_merge($git, $config);
    unset($postdata['license']);
    $options = array('http' => array('method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . "X-License-Key: {$config['license']}\r\n", 'content' => http_build_query(array('deployment' => $postdata))));
    $context = stream_context_create($options);
    $result = @file_get_contents('https://api.newrelic.com/deployments.xml', false, $context);
    if ($result === false) {
        throw new \RuntimeException($php_errormsg);
    }
});
Exemple #6
0
<?php

desc("start selenium");
task("selenium:run", null, function ($argv) {
    $path = ROOT . "vendor/Selenium-Server/selenium-server.jar";
    system("java -jar {$path}");
});
desc("test one test");
task("test", null, function ($argv) {
    Tab\Tab::addIncludePaths(ROOT . "test/", ROOT . "test/Midori");
    require "tests-bootstrap.php";
    $argv = $argv->args;
    if (count($argv) == 1) {
        $args = array("Single Test");
        foreach ($argv as $item) {
            $args[] = $item;
        }
    }
    $_SERVER['argv'] = $args;
    require_once 'PHPUnit/Util/Filter.php';
    require_once 'Midori/PHPUnit/Spec.php';
    PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
    require 'PHPUnit/TextUI/Command.php';
    define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
    PHPUnit_TextUI_Command::main();
});
Exemple #7
0
<?php

/* (c) Laurent Goussard <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

/**
 * Get local username
 */
set('local_user', function () {
    return trim(run("whoami"));
});
desc('Notifying Rollbar of deployment');
task('deploy:rollbar', function () {
    global $php_errormsg;
    $defaultConfig = ['access_token' => null, 'environment' => get('stages')[0], 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'local_username' => trim(runLocally('git config user.name')), 'rollbar_username' => null, 'comment' => "Deployment to `{{host}}` on *{{stage}}* was successful\n({{release_path}})"];
    $config = array_merge($defaultConfig, (array) get('rollbar', []));
    if (!is_array($config) || !isset($config['access_token'])) {
        throw new \RuntimeException("Please configure new rollbar: set('rollbar', ['access_token' => 'c09a3...', 'revision' => 'v4.3', 'rollbar_username' => 'John Doe', 'comment' => 'Brand new version']);");
    }
    $server = \Deployer\Task\Context::get()->getServer();
    if ($server instanceof \Deployer\Server\Local) {
        $user = get('local_user');
    } else {
        $user = $server->getConfiguration()->getUser() ?: null;
    }
    $commentPlaceHolders = ['{{release_path}}' => get('release_path'), '{{host}}' => get('server.host'), '{{stage}}' => get('stages')[0], '{{user}}' => $user, '{{branch}}' => get('branch')];
    $config['comment'] = strtr($config['comment'], $commentPlaceHolders);
Exemple #8
0
<?php

/**
 * file create task
 */
desc("File create task");
task("create_file", function () {
    touch("/tmp/hogehoge");
});
desc("File delete task");
task("delete_file", array("create_file"), function () {
    unlink("/tmp/hogehoge");
});
Exemple #9
0
<?php

/* (c) Tim Robertson <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Notifying Bugsnag of deployment');
task('deploy:bugsnag', function () {
    global $php_errormsg;
    $defaultConfig = ['api_key' => null, 'release_stage' => get('stages')[0], 'repository' => get('repository'), 'provider' => null, 'branch' => get('branch'), 'revision' => trim(runLocally('git log -n 1 --format="%h"')), 'app_version' => null];
    $config = array_merge($defaultConfig, (array) get('bugsnag'));
    if (!is_array($config) || !isset($config['api_key'])) {
        throw new \RuntimeException("Please configure new bugsnag: set('bugsnag', ['api_key' => 'c09a3...', 'release_stage' => 'production']);");
    }
    $postdata = ['apiKey' => $config['api_key'], 'releaseStage' => $config['release_stage'], 'repository' => $config['repository'], 'provider' => $config['provider'], 'branch' => $config['branch'], 'revision' => $config['revision'], 'appVersion' => $config['app_version']];
    $options = array('http' => array('method' => 'POST', 'header' => "Content-type: application/json\r\n", 'content' => json_encode($postdata)));
    $context = stream_context_create($options);
    $result = @file_get_contents('https://notify.bugsnag.com/deploy', false, $context);
    if (!$result) {
        throw new \RuntimeException($php_errormsg);
    }
});
Exemple #10
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Preparing server for deploy');
task('deploy:prepare', function () {
    // Check if shell is POSIX-compliant
    try {
        cd('');
        // To run command as raw.
        $result = run('echo $0')->toString();
        if ($result == 'stdin: is not a tty') {
            throw new \RuntimeException("Looks like ssh inside another ssh.\n" . "Help: http://goo.gl/gsdLt9");
        }
    } catch (\RuntimeException $e) {
        $formatter = Deployer::get()->getHelper('formatter');
        $errorMessage = ["Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.", "Usually, you can change your shell to bash by running: chsh -s /bin/bash"];
        write($formatter->formatBlock($errorMessage, 'error', true));
        throw $e;
    }
    run('if [ ! -d {{deploy_path}} ]; then mkdir -p {{deploy_path}}; fi');
    // Check for existing /current directory (not symlink)
    $result = run('if [ ! -L {{deploy_path}}/current ] && [ -d {{deploy_path}}/current ]; then echo true; fi')->toBool();
    if ($result) {
        throw new \RuntimeException('There already is a directory (not symlink) named "current" in ' . get('deploy_path') . '. Remove this directory so it can be replaced with a symlink for atomic deployments.');
    }
Exemple #11
0
    }
    return implode(' ', $optionsRsync);
});
desc('Warmup remote Rsync target');
task('rsync:warmup', function () {
    $config = get('rsync');
    $releases = get('releases_list');
    if (isset($releases[1])) {
        $source = "{{deploy_path}}/releases/{$releases[1]}";
        $destination = "{{deploy_path}}/releases/{$releases[0]}";
        run("rsync -{$config['flags']} {{rsync_options}}{{rsync_excludes}}{{rsync_includes}}{{rsync_filter}} {$source}/ {$destination}/");
    } else {
        writeln("<comment>No way to warmup rsync.</comment>");
    }
});
desc('Rsync local->remote');
task('rsync', function () {
    $config = get('rsync');
    $src = get('rsync_src');
    while (is_callable($src)) {
        $src = $src();
    }
    if (!trim($src)) {
        // if $src is not set here rsync is going to do a directory listing
        // exiting with code 0, since only doing a directory listing clearly
        // is not what we want to achieve we need to throw an exception
        throw new \RuntimeException('You need to specify a source path.');
    }
    $dst = get('rsync_dest');
    while (is_callable($dst)) {
        $dst = $dst();
Exemple #12
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Cleaning up old releases');
task('cleanup', function () {
    $releases = get('releases_list');
    $keep = get('keep_releases');
    if ($keep === -1) {
        // Keep unlimited releases.
        return;
    }
    while ($keep - 1 > 0) {
        array_shift($releases);
        --$keep;
    }
    foreach ($releases as $release) {
        run("rm -rf {{deploy_path}}/releases/{$release}");
    }
    run("cd {{deploy_path}} && if [ -e release ]; then rm release; fi");
    run("cd {{deploy_path}} && if [ -h release ]; then rm release; fi");
});
Exemple #13
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Installing vendors');
task('deploy:vendors', function () {
    run('cd {{release_path}} && {{env_vars}} {{bin/composer}} {{composer_options}}');
});
Exemple #14
0
<?php

/**
 * directory task
 */
desc("Directory Create task");
task("create_dir", function () {
    mkdir("/tmp/hogehoge");
});
desc("Directory delete task");
task("delete_dir", array("create_dir"), function () {
    rmdir("/tmp/hogehoge");
});
Exemple #15
0
<?php

/*
 * Put the `bob_config.php` into the "Bob" namespace,
 * otherwise you would've to call the `task` and
 * `desc` functions with a `Bob\` prefix.
 */
namespace Bob\BuildConfig;

task('default', array('test'));
desc("Runs all tests");
task('test', array('composer.lock'), function () {
    if (!file_exists('phpunit.xml')) {
        copy('phpunit.dist.xml', 'phpunit.xml');
    }
    echo sh('phpunit');
});
desc('Runs "composer update" when the composer.json was changed');
fileTask('composer.lock', array('composer.json'), function ($task) {
    echo sh('composer update');
});
Exemple #16
0
    }
});
desc('Installing vendors locally');
task('local:vendors', function () {
    runLocally("cd {{local_release_path}} && {{env_vars}} {{local_bin/composer}} {{composer_options}}");
});
desc('Creating symlink to local release');
task('local:symlink', function () {
    runLocally("cd {{local_deploy_path}} && ln -sfn {{local_release_path}} current");
    // Atomic override symlink.
    runLocally("cd {{local_deploy_path}} && rm release");
    // Remove release link.
});
desc('Show current local release.');
task('local:current', function () {
    writeln('Current local release: ' . basename(get('local_current')));
});
desc('Cleaning up old local releases');
task('local:cleanup', function () {
    $releases = get('local_releases_list');
    $keep = get('keep_releases');
    while ($keep > 0) {
        array_shift($releases);
        --$keep;
    }
    foreach ($releases as $release) {
        runLocally("rm -rf {{local_deploy_path}}/releases/{$release}");
    }
    runLocally("cd {{local_deploy_path}} && if [ -e release ]; then rm release; fi");
    runLocally("cd {{local_deploy_path}} && if [ -h release ]; then rm release; fi");
});
Exemple #17
0
desc('Clearing APC system cache');
task('cachetool:clear:apc', function () {
    $releasePath = get('release_path');
    $options = get('cachetool');
    if (strlen($options)) {
        $options = "--fcgi={$options}";
    }
    cd($releasePath);
    $hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
    if ('true' !== $hasCachetool) {
        run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
    }
    run("{{bin/php}} cachetool.phar apc:cache:clear system {$options}");
});
/**
 * Clear opcache cache
 */
desc('Clearing OPcode cache');
task('cachetool:clear:opcache', function () {
    $releasePath = get('release_path');
    $options = get('cachetool');
    if (strlen($options)) {
        $options = "--fcgi={$options}";
    }
    cd($releasePath);
    $hasCachetool = run("if [ -e {$releasePath}/cachetool.phar ]; then echo 'true'; fi");
    if ('true' !== $hasCachetool) {
        run("curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar");
    }
    run("{{bin/php}} cachetool.phar opcache:reset {$options}");
});
Exemple #18
0
heading('slug_name()');
desc('Converts a string into a "slug", suitable for file names, css class names, etc.');
$slug_tests = array('This/That', 'Adobe&reg;', 'Kevlar&trade;', 'Who Needs This?');
foreach ($slug_tests as $test) {
    example("echo slug_name('{$test}')");
}
heading('place_image()');
example('echo place_image("alf.jpg")');
example('echo place_image("alf")', 'works without the file extension if there is a corresponding gif, jpg, or png');
example('echo place_image("test-png")');
example('echo place_image("test-gif")');
example('echo place_image("test-jpg")');
example('echo place_image("non-existing-file")', "doesn't output anything if it can't find the file");
heading('content_tag()');
desc('Wraps content in an html tag. Specify the attributes for the tag as an array in the third parameter.');
example("echo content_tag('h3', 'My Custom H3 Tag')");
example("echo content_tag('p', 'My Custom P Tag')");
example('echo content_tag(\'p\', \'My Custom P Tag with attributes\', $tag_attributes=array(\'id\' => \'custom_id\', \'class\' => \'custom_class\'))', 'add an array of attributes to the tag');
heading('title_tag()');
desc('Creates the <title> tag for the page based on the configuration and page values.');
heading('meta_tags()');
desc('Creates the meta keywords and meta description tags based on the configuration and page values.');
heading('ie6_alert()');
desc('Displays an html pop-up if browser is IE6.');
//example('echo ie6_alert()');
print_logr();
?>

</div>
</body>
</html>
Exemple #19
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Update code');
task('deploy:update_code', function () {
    $repository = trim(get('repository'));
    $branch = get('branch');
    $git = get('bin/git');
    $gitCache = get('git_cache');
    $depth = $gitCache ? '' : '--depth 1';
    // If option `branch` is set.
    if (input()->hasOption('branch')) {
        $inputBranch = input()->getOption('branch');
        if (!empty($inputBranch)) {
            $branch = $inputBranch;
        }
    }
    // Branch may come from option or from configuration.
    $at = '';
    if (!empty($branch)) {
        $at = "-b {$branch}";
    }
    // If option `tag` is set
    if (input()->hasOption('tag')) {
        $tag = input()->getOption('tag');
<?php

/**
 * Hello world task
 */
desc("Hello World task");
task("hello_world", function () {
    echo "Hello World !\n";
});
desc("hello pask!");
task("hello_pask", function () {
    echo "Hello Pask !\n";
});
Exemple #21
0
/* (c) Tomas Majer <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

/**
 * Get local username
 */
set('local_user', function () {
    return trim(run("whoami"));
});
// Do not skip slack notifications by default
set('slack_skip_notification', false);
desc('Notifying Slack channel of deployment');
task('deploy:slack', function () {
    if (true === get('slack_skip_notification')) {
        return;
    }
    global $php_errormsg;
    $defaultConfig = ['channel' => '#general', 'icon' => ':sunny:', 'username' => 'Deploy', 'message' => "Deployment to `{{host}}` on *{{stage}}* was successful\n({{release_path}})", 'app' => 'app-name'];
    $config = array_merge($defaultConfig, (array) get('slack'));
    if (!is_array($config) || !isset($config['token']) || !isset($config['team']) || !isset($config['channel'])) {
        throw new \RuntimeException("Please configure new slack: set('slack', ['token' => 'xoxp...', 'team' => 'team', 'channel' => '#channel', 'messsage' => 'message to send']);");
    }
    $server = \Deployer\Task\Context::get()->getServer();
    if ($server instanceof \Deployer\Server\Local) {
        $user = get('local_user');
    } else {
        $user = $server->getConfiguration()->getUser() ?: null;
Exemple #22
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Lock deploy');
task('deploy:lock', function () {
    $locked = run("if [ -f {{deploy_path}}/.dep/deploy.lock ]; then echo 'true'; fi")->toBool();
    if ($locked) {
        throw new \RuntimeException("Deploy locked.\n" . "Run deploy:unlock command to unlock.");
    } else {
        run("touch {{deploy_path}}/.dep/deploy.lock");
    }
});
desc('Unlock deploy');
task('deploy:unlock', function () {
    run("rm {{deploy_path}}/.dep/deploy.lock");
});
Exemple #23
0
 *
 * @return array Array of options
 */
set('phinx_get_allowed_config', function ($allowedOptions) {
    $opts = [];
    try {
        foreach (get('phinx') as $key => $val) {
            if (in_array($key, $allowedOptions)) {
                $opts[$key] = $val;
            }
        }
    } catch (\RuntimeException $e) {
    }
    return $opts;
});
desc('Migrating database by phinx');
task('phinx:migrate', function () {
    $ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
    $conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
    cd('{{release_path}}');
    $phinxCmd = get('phinx_get_cmd')('migrate', $conf);
    run($phinxCmd);
    cd('{{deploy_path}}');
});
task('phinx:rollback', function () {
    $ALLOWED_OPTIONS = ['configuration', 'date', 'environment', 'target', 'parser'];
    $conf = get('phinx_get_allowed_config')($ALLOWED_OPTIONS);
    cd('{{release_path}}');
    $phinxCmd = get('phinx_get_cmd')('rollback', $conf);
    run($phinxCmd);
    cd('{{deploy_path}}');
    file_put_contents('_includes/cmd-list.html', render('cmd-list.mustache', $wp));
    foreach ($wp['subcommands'] as $cmd) {
        gen_cmd_pages($cmd);
    }
});
desc('Update the /config/ page.');
task('param-list', function ($app) {
    $config_spec = invoke_wp_cli('wp cli param-dump', $app);
    $out = '';
    foreach ($config_spec as $key => $details) {
        if (isset($details['hidden']) || isset($details['deprecated'])) {
            continue;
        }
        if (false !== $details['file']) {
            $config = "{$key}: " . $details['file'];
        } else {
            $config = '';
        }
        if (false !== $details['runtime']) {
            $flag = true === $details['runtime'] ? "--[no-]{$key}" : "--{$key}" . $details['runtime'];
        } else {
            $flag = '';
        }
        $default = json_encode($details['default']);
        $description = isset($details['desc']) ? $details['desc'] : '';
        $out .= render('config.mustache', compact('config', 'flag', 'default', 'description'));
    }
    file_put_contents('_includes/param-list.html', $out);
});
desc('Build the site.');
task('default', 'cmd-list', 'param-list');
Exemple #25
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

set('bin/npm', function () {
    return (string) run('which npm');
});
desc('Install npm packages');
task('npm:install', function () {
    $releases = get('releases_list');
    if (isset($releases[1])) {
        if (run("if [ -d {{deploy_path}}/releases/{$releases[1]}/node_modules ]; then echo 'true'; fi")->toBool()) {
            run("cp --recursive {{deploy_path}}/releases/{$releases[1]}/node_modules {{release_path}}");
        }
    }
    run("cd {{release_path}} && {{bin/npm}} install");
});
Exemple #26
0
<?php

desc("lists all the tasks");
task("-T", null, function () {
    $application = \Tab\Tab::getInstance()->application;
    $tasks = $application->tasks;
    usort($tasks, function ($a, $b) {
        return strcmp($a->name, $b->name);
    });
    echo "\n  " . str_pad("Tasks", 40) . "Description\n";
    foreach ($tasks as $task) {
        echo "  " . str_pad($task->name, 40) . $task->description . "\n";
    }
});
desc("gives the version");
task("-v", null, function () {
    echo "tab-php: v1 alpha";
});
Exemple #27
0
<?php

namespace Bob\BuildConfig;

task("default", array("test"));
desc("Runs all tests.");
task("test", array("phpunit.xml", "composer.json"), function () {
    sh("./vendor/bin/phpunit");
});
fileTask("phpunit.xml", array("phpunit.dist.xml"), function ($task) {
    copy($task->prerequisites[0], $task->name);
});
fileTask("composer.json", array("composer.lock"), function ($task) {
    if (!file_exists("composer.phar")) {
        file_put_contents("composer.phar", file_get_contents("http://getcomposer.org/composer.phar"));
    }
    php("composer.phar install --dev");
});
Exemple #28
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Creating symlink to release');
task('deploy:symlink', function () {
    if (run('if [[ "$(man mv)" =~ "--no-target-directory" ]]; then echo "true"; fi')->toBool()) {
        run("mv -T {{deploy_path}}/release {{deploy_path}}/current");
    } else {
        // Atomic symlink does not supported.
        // Will use simple≤ two steps switch.
        run("cd {{deploy_path}} && {{bin/symlink}} {{release_path}} current");
        // Atomic override symlink.
        run("cd {{deploy_path}} && rm release");
        // Remove release link.
    }
});
Exemple #29
0
desc('Execute artisan view:clear');
task('artisan:view:clear', function () {
    run('{{bin/php}} {{release_path}}/artisan view:clear');
});
desc('Execute artisan optimize');
task('artisan:optimize', function () {
    run('{{bin/php}} {{release_path}}/artisan optimize');
});
/**
 * Task deploy:public_disk support the public disk.
 * To run this task automatically, please add below line to your deploy.php file
 *
 *     before('deploy:symlink', 'deploy:public_disk');
 *
 * @see https://laravel.com/docs/5.2/filesystem#configuration
 */
desc('Make symlink for public disk');
task('deploy:public_disk', function () {
    // Remove from source.
    run('if [ -d $(echo {{release_path}}/public/storage) ]; then rm -rf {{release_path}}/public/storage; fi');
    // Create shared dir if it does not exist.
    run('mkdir -p {{deploy_path}}/shared/storage/app/public');
    // Symlink shared dir to release dir
    run('{{bin/symlink}} {{deploy_path}}/shared/storage/app/public {{release_path}}/public/storage');
});
/**
 * Main task
 */
desc('Deploy your project');
task('deploy', ['deploy:prepare', 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', 'deploy:vendors', 'deploy:writable', 'artisan:view:clear', 'artisan:cache:clear', 'artisan:config:cache', 'artisan:optimize', 'deploy:symlink', 'deploy:unlock', 'cleanup']);
after('deploy', 'success');
Exemple #30
0
<?php

/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Deployer;

desc('Copy directories');
task('deploy:copy_dirs', function () {
    $dirs = get('copy_dirs');
    foreach ($dirs as $dir) {
        // Delete directory if exists.
        run("if [ -d \$(echo {{release_path}}/{$dir}) ]; then rm -rf {{release_path}}/{$dir}; fi");
        // Copy directory.
        run("if [ -d \$(echo {{deploy_path}}/current/{$dir}) ]; then cp -rpf {{deploy_path}}/current/{$dir} {{release_path}}/{$dir}; fi");
    }
});