-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdeploy.php
More file actions
170 lines (139 loc) · 4.19 KB
/
Copy pathdeploy.php
File metadata and controls
170 lines (139 loc) · 4.19 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
declare(strict_types=1);
namespace Deployer;
require 'recipe/laravel.php';
/*
|--------------------------------------------------------------------------
| Application
|--------------------------------------------------------------------------
*/
set('application', 'bladewindui.com');
set('repository', 'git@github.com:mkocansey/bladewind-docs.git');
set('branch', 'main');
set('keep_releases', 3);
set('composer_options', implode(' ', [
'--no-dev',
'--prefer-dist',
'--no-interaction',
'--no-progress',
'--optimize-autoloader',
]));
add('shared_files', [
'.env',
'database/database.sqlite',
]);
add('shared_dirs', [
'storage',
]);
set('writable_mode', 'chmod');
set('writable_chmod_mode', '0775');
set('writable_chmod_recursive', true);
set('writable_use_sudo', false);
/*
|--------------------------------------------------------------------------
| Host
|--------------------------------------------------------------------------
*/
host('production')
->setHostname('bladewindui.com')
->setRemoteUser('mkocansey')
->set('branch', 'main')
->setDeployPath('/var/www/html/{{application}}')
->setLabels([
'stage' => 'production',
]);
/*
|--------------------------------------------------------------------------
| Node.js
|--------------------------------------------------------------------------
*/
set(
'nvm',
'export NVM_DIR="$HOME/.nvm"'
. ' && [ -s "$NVM_DIR/nvm.sh" ]'
. ' && . "$NVM_DIR/nvm.sh"'
);
set('node_version', '20');
/*
|--------------------------------------------------------------------------
| Deployment tasks
|--------------------------------------------------------------------------
*/
desc('Install frontend dependencies and build production assets');
task('deploy:assets', function (): void {
within('{{release_path}}', function (): void {
run('node --version');
run('npm --version');
if (test('[ -f package-lock.json ]')) {
run('npm ci --no-audit --no-fund');
} else {
run('npm install --no-audit --no-fund');
}
run('npm run build');
});
});
desc('Verify the release before making it live');
task('deploy:verify', function (): void {
if (! test('[ -f {{release_path}}/vendor/autoload.php ]')) {
throw new \RuntimeException(
'Deployment aborted: vendor/autoload.php is missing.'
);
}
if (! test('[ -f {{release_path}}/artisan ]')) {
throw new \RuntimeException(
'Deployment aborted: artisan is missing.'
);
}
if (! test('[ -f {{release_path}}/public/index.php ]')) {
throw new \RuntimeException(
'Deployment aborted: public/index.php is missing.'
);
}
});
desc('Reload PHP-FPM');
task('php-fpm:reload', function (): void {
run('sudo /usr/bin/systemctl reload php8.4-fpm');
});
/*
|--------------------------------------------------------------------------
| Deployment flow
|--------------------------------------------------------------------------
|
| Nothing is executed against "current" until deploy:publish updates the
| symlink. Composer, migrations, optimization and frontend compilation all
| run inside the new release directory first.
|
*/
desc('Deploy Bladewind documentation to production');
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'artisan:publish-bladewind-assets',
'artisan:storage:link',
'artisan:migrate',
'artisan:optimize',
'deploy:assets',
'deploy:verify',
'deploy:publish',
'php-fpm:reload',
]);
desc('Publish Bladewind UI public assets');
task('artisan:publish-bladewind-assets', function (): void {
within('{{release_path}}', function (): void {
run('php artisan vendor:publish --tag=bladewind-public --force');
});
});
desc('Confirm and deploy interactively');
task('build', function (): void {
if (! askConfirmation('Deploy to production?', false)) {
warning('Deployment aborted.');
return;
}
invoke('deploy');
});
/*
|--------------------------------------------------------------------------
| Failure handling
|--------------------------------------------------------------------------
*/
after('deploy:failed', 'deploy:unlock');