mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Deployer;
|
|
|
|
desc('Creating symlinks for shared files and dirs');
|
|
task('deploy:shared', function () {
|
|
$sharedPath = "{{deploy_path}}/shared";
|
|
|
|
foreach (get('shared_dirs') as $dir) {
|
|
$parentDir = dirname($dir);
|
|
|
|
// Create shared dir if it does not exist.
|
|
run("mkdir -p $sharedPath/$dir");
|
|
|
|
// Copy shared dir files if they does not exist.
|
|
run("if [ -d $(echo {{release_path}}/$dir) ]; then cp -rn {{release_path}}/$dir $sharedPath/$parentDir; fi");
|
|
|
|
// Remove from source.
|
|
run("if [ -d $(echo {{release_path}}/$dir) ]; then rm -rf {{release_path}}/$dir; fi");
|
|
|
|
// Create path to shared dir in release dir if it does not exist.
|
|
// (symlink will not create the path and will fail otherwise)
|
|
run("mkdir -p `dirname {{release_path}}/$dir`");
|
|
|
|
// Symlink shared dir to release dir
|
|
run("{{bin/symlink}} $sharedPath/$dir {{release_path}}/$dir");
|
|
}
|
|
|
|
foreach (get('shared_files') as $file) {
|
|
$dirname = dirname($file);
|
|
// Remove from source.
|
|
run("if [ -f $(echo {{release_path}}/$file) ]; then rm -rf {{release_path}}/$file; fi");
|
|
|
|
// Ensure dir is available in release
|
|
run("if [ ! -d $(echo {{release_path}}/$dirname) ]; then mkdir -p {{release_path}}/$dirname;fi");
|
|
|
|
// Create dir of shared file
|
|
run("mkdir -p $sharedPath/" . $dirname);
|
|
|
|
// Touch shared
|
|
run("touch $sharedPath/$file");
|
|
|
|
// Symlink shared dir to release dir
|
|
run("{{bin/symlink}} $sharedPath/$file {{release_path}}/$file");
|
|
}
|
|
});
|