我创建了一个Envoy.blade.php文件进行部署,但是,当我运行envoy run deploy
时,出现语法错误。我试图找到错误,但没有看到。
Envoy.blade.php
@setup
// user on web-server
$user = 'root';
$timezone = 'Europe/Moscow';
// path to the directory on web-server
$path = '/var/www/';
$current = path . '/current';
// where take your code (git clone)
$repo = 'git@github.com';
$branch = 'master';
// Directory and files with chmod 755
$chmod = [
'storage/logs'
];
$date = new DateTime('now', new DateTimeZone($timezone));
$release = $path .'/release'. $date->format('YmdHis');
@endsetup
@servers(['production' => $user . '@5.453.20.189'])
@task('clone', ['on' => $on])
mkdir -p {{ $release }}
git clone --depth l -b {{ $branch }} "{{ $repo }}" {{ $release }}
echo "#1 - Repository has been cloned"
@endtask
{{-- Runs a fresh installation --}}
@task('composer', ['on' => $on])
composer self-update
cd {{ $release }}
composer install --no-interaction --no-dev --prefer-dist
echo "#2 - Composer dependencies have been installed"
@endtask
{{-- Updates composer, then runs a fresh unstallation --}}
@task('artisan', ['on' => $on])
cd {{ $release }}
ln -nfs {{ $path }}/.env .env;
chfrp -h www-data .env;
php artisan config:clear
php artisan migrate
php artisan clear-compiled --env-production;
php artisan optimize --env-production;
echo "#3 Production dependencies have been installed"
@endtask
{{-- Set permissions for various files and directories --}}
@task('chmod', ['on' => $on])
chgrp -R www-data {{ $release }};
chmod -R ug+rwx {{ $release }};
@foreach($chmod as $file)
chmod -R 775 {{ $release }}/{{ $file }}
chown -R {{ $user }}:www-data {{ $release }}/{{ $file }}
echo "Permissions have been set for {{ $file }}"
@endforeach
echo "#4 - Permissions has been set"
@endtask
@task('update_symlinks')
ln -nfs {{ $release }} {{ $current }};
chgrp -h www-data {{ $current }};
echo "#5 - Symlinks has beeb set"
@endtask
{{-- Run all deployment task --}}
@macro('deploy', ['on', => 'production'])
clone
composer
artisan
chmod
update_symlinks
@endmacro
运行命令envoy run deploy
后,在第79行出现错误。请帮我找到错误。
答案 0 :(得分:0)
这里有几个问题,它们在上面的评论中列出。请尝试以下操作。
@setup
$user = 'root';
$timezone = 'Europe/Moscow';
$path = '/var/www/';
$current = $path . '/current';
$repo = 'git@github.com';
$branch = 'master';
$chmod = [
'storage/logs'
];
$date = new DateTime('now', new DateTimeZone($timezone));
$release = $path .'/release'. $date->format('YmdHis');
@endsetup
@servers(['production' => $user . '@5.453.20.189'])
{{-- Run all deployment tasks --}}
@macro('deploy', ['on' => 'production'])
clone
composer
artisan
chmod
update_symlinks
@endmacro
@task('clone', ['on' => $on])
mkdir -p {{ $release }}
git clone --depth l -b {{ $branch }} "{{ $repo }}" {{ $release }}
echo "#1 - Repository has been cloned"
@endtask
{{-- Runs a fresh installation --}}
@task('composer', ['on' => $on])
composer self-update
cd {{ $release }}
composer install --no-interaction --no-dev --prefer-dist
echo "#2 - Composer dependencies have been installed"
@endtask
{{-- Updates composer, then runs a fresh unstallation --}}
@task('artisan', ['on' => $on])
cd {{ $release }}
ln -nfs {{ $path }}/.env .env;
chfrp -h www-data .env;
php artisan config:clear
php artisan migrate
php artisan clear-compiled --env-production;
php artisan optimize --env-production;
echo "#3 Production dependencies have been installed"
@endtask
{{-- Set permissions for various files and directories --}}
@task('chmod', ['on' => $on])
chgrp -R www-data {{ $release }};
chmod -R ug+rwx {{ $release }};
@foreach($chmod as $file)
chmod -R 775 {{ $release }}/{{ $file }}
chown -R {{ $user }}:www-data {{ $release }}/{{ $file }}
echo "Permissions have been set for {{ $file }}"
@endforeach
echo "#4 - Permissions has been set"
@endtask
@task('update_symlinks')
ln -nfs {{ $release }} {{ $current }};
chgrp -h www-data {{ $current }};
echo "#5 - Symlinks has beeb set"
@endtask