Skip to content

Commit

Permalink
Add new deploy:env recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 19, 2024
1 parent 74c5307 commit 9db20b3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions recipe/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require __DIR__ . '/deploy/cleanup.php';
require __DIR__ . '/deploy/clear_paths.php';
require __DIR__ . '/deploy/copy_dirs.php';
require __DIR__ . '/deploy/env.php';
require __DIR__ . '/deploy/info.php';
require __DIR__ . '/deploy/lock.php';
require __DIR__ . '/deploy/push.php';
Expand Down Expand Up @@ -141,6 +142,7 @@
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:env',
'deploy:shared',
'deploy:writable',
]);
Expand Down
12 changes: 12 additions & 0 deletions recipe/deploy/env.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Deployer;

desc('Configure .env file');
task('deploy:env', function () {
cd('{{release_path}}');
if (test('[ -f .env.example ]')) {
run('cp .env.example .env');
set('new_deployment', true);
}
});
8 changes: 8 additions & 0 deletions recipe/laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ function laravel_version_compare($version, $comparator)
desc('Sets the application key');
task('artisan:key:generate', artisan('key:generate'));

desc('Generates the application key for new deployments');
task('artisan:create_key', function () {
if (has('new_deployment')) {
invoke('artisan:key:generate');
}
})->hidden();

desc('Creates the encryption keys for API authentication');
task('artisan:passport:keys', artisan('passport:keys'));

Expand Down Expand Up @@ -275,6 +282,7 @@ function laravel_version_compare($version, $comparator)
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'artisan:create_key',
'artisan:storage:link',
'artisan:config:cache',
'artisan:route:cache',
Expand Down
2 changes: 1 addition & 1 deletion recipe/provision/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
rewrite @404 /404.html
file_server {
root /var/dep/html
root /var/deployer
}
}
}

0 comments on commit 9db20b3

Please sign in to comment.