-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnvoy.blade.php
103 lines (75 loc) · 2.45 KB
/
Envoy.blade.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
@servers(['local' => '127.0.0.1', 'staging' => ['[email protected]','[email protected]']])
@setup
// the repository to clone
// $repo = '[email protected]:ahaneef29/php-shop.git';
$repo = 'https://github.com/ahaneef29/Nordic-Store.git';
// the branch to clone
$branch = 'master';
// set up timezones
date_default_timezone_set('Asia/Dubai');
// we want the releases to be timestamps to ensure uniqueness
$date = date('YmdHis');
// the application directory on your server
$appDir = '/var/www/html';
// this is where the releases will be stored
$buildsDir = $appDir . '/releases';
// this is where the deployment will be
$deploymentDir = $buildsDir . '/' . $date;
// and this is the document root directory
$serve = $appDir . '/current';
@endsetup
@task('dir')
echo "Preparing new deployment directory..."
mkdir -p {{ $buildsDir }}
cd {{ $buildsDir }}
mkdir -p {{ $date }}
echo "Preparing new deployment directory complete."
@endtask
@task('git')
echo "Cloning repository..."
cd {{ $deploymentDir }}
git clone --depth 1 -b {{ $branch }} "{{ $repo }}" {{ $deploymentDir }}
echo "Cloning repository complete."
@endtask
@task('install')
echo "Installing dependencies...";
{{-- composer install --prefer-dist
cp ../../wp-config.php ./wp-config.php --}}
echo "Installing dependencies complete."
@endtask
@task('live')
echo "Creating symlinks for the live version..."
cd {{ $deploymentDir }}
ln -nfs {{ $deploymentDir }} {{ $serve }}
{{-- ln -nfs {{ $appDir }}/uploads {{ $serve }}/wp-content/ --}}
echo "Creating symlinks completed."
@endtask
@task('rollback')
echo ">>". $buildsDir;
cd {{ $buildsDir }}
ln -nfs {{ $buildsDir }}/$(find . -maxdepth 1 -name "20*" | sort | tail -n 2 | head -n1) {{ $serve }}
echo "Rolled back to $(find . -maxdepth 1 -name "20*" | sort | tail -n 2 | head -n1)"
@endtask
@task('deployment_cleanup')
echo "Cleaning up old deployments..."
cd {{ $buildsDir }}
ls -t | tail -n +4 | xargs rm -rf
echo "Cleaned up old deployments."
@endtask
@story('rollback', ['on' => 'staging'])
rollback
@endstory
@story('deploy-staging', ['on' => 'staging'])
dir
git
{{-- install --}}
live
deployment_cleanup
@endstory
{{-- @story('deploy-production', ['on' => 'production'])
dir
git
install
live
deployment_cleanup
@endstory --}}