forked from jacmoe/pype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
65 lines (54 loc) · 2.3 KB
/
deploy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Deployer;
require_once __DIR__ . '/deployer/recipe/yii-configure.php';
require_once __DIR__ . '/deployer/recipe/yii2-app-basic.php';
require_once __DIR__ . '/deployer/recipe/local-config.php';
/*
* This file is part of
* _ __ _ _ _ __ ___
* | '_ \| | | | '_ \ / _ \
* | |_) | |_| | |_) | __/
* | .__/ \__, | .__/ \___|
* |_| |___/|_|
* Personal Yii Page Engine
*
* Copyright (c) 2016 - 2017 Jacob Moen
* Licensed under the MIT license
*/
if (!file_exists (__DIR__ . '/deployer/stage/servers.yml')) {
die('Please create "' . __DIR__ . '/deployer/stage/servers.yml" before continuing.' . "\n");
}
inventory(__DIR__ . '/deployer/stage/servers.yml');
set('repository', '{{repository}}');
set('default_stage', 'production');
set('keep_releases', 2);
set('writable_use_sudo', false); // Using sudo in writable commands?
task('deploy:configure_composer', function () {
$stage = get('app_stage');
if($stage == 'dev') {
set('composer_options', 'install --verbose --no-progress --no-interaction');
}
})->desc('Configure composer');
// build assets
task('deploy:build_assets', function () {
runLocally('gulp build --production');
upload(__DIR__ . '/themes/bourbon/assets/dist/css', '{{release_path}}/themes/bourbon/assets/dist/css');
upload(__DIR__ . '/themes/bourbon/assets/dist/js', '{{release_path}}/themes/bourbon/assets/dist/js');
upload(__DIR__ . '/themes/bourbon/assets/dist/fonts', '{{release_path}}/themes/bourbon/assets/dist/fonts');
upload(__DIR__ . '/themes/bourbon/assets/dist/img', '{{release_path}}/themes/bourbon/assets/dist/img');
})->desc('Build assets');
// update symlink to images dir
task('deploy:images_symlink', function () {
run('{{bin/php}} {{release_path}}/yii mdpages/pages/symlink');
})->desc('Update images symlink');
task('flush_cache', function () {
run('{{bin/php}} {{release_path}}/yii cache/flush-all');
})->desc('Flush the cache');
task('flush_templates', function() {
$templatePath = "{{deploy_path}}/shared/runtime/Jade";
run("if [ -d $(echo $templatePath) ]; then rm -rf $templatePath; fi");
})->desc('Flush the templates');
after('deploy:shared', 'deploy:configure');
before('deploy:vendors', 'deploy:configure_composer');
after('deploy:vendors', 'deploy:build_assets');
after('deploy:build_assets', 'deploy:images_symlink');