-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.php
More file actions
34 lines (30 loc) · 1.2 KB
/
deploy.php
File metadata and controls
34 lines (30 loc) · 1.2 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
<?php
namespace Deployer;
require 'recipe/laravel.php';
set('repository', 'https://github.com/naisimemeda/hairpin.git');
add('shared_files', []);
add('shared_dirs', []);
set('writable_dirs', []);
host('47.94.224.250')
->user('root') // 使用 root 账号登录
->identityFile('~/.ssh/hairpin.pem') // 指定登录密钥文件路径
->become('www-data') // 以 www-data 身份执行命令
->set('deploy_path', '/var/www/hairpin-deployer'); // 指定部署目录
add('copy_dirs', ['vendor']);
after('deploy:failed', 'deploy:unlock');
before('deploy:symlink', 'artisan:migrate');
desc('Upload .env file');
desc('Restart Horizon');
task('horizon:terminate', function() {
run('{{bin/php}} {{release_path}}/artisan horizon:terminate');
});
// 在 deploy:symlink 任务之后执行 horizon:terminate 任务
after('deploy:symlink', 'horizon:terminate');
task('env:upload', function() {
// 将本地的 .env 文件上传到代码目录的 .env
upload('.env', '{{release_path}}/.env');
});
before('deploy:vendors', 'deploy:copy_dirs');
// 定义一个后置钩子,在 deploy:shared 之后执行 env:upload 任务
after('deploy:shared', 'env:upload');
after('artisan:config:cache', 'artisan:route:cache');