I'm an absolute noob with Capistrano (v 3.2.1), so please forgive my, err, uselessness. I'm deploying a PHP app and wish to run composer install before the deploy:symlink:release task (only when not running a rollback)
I'm having trouble accessing the newly created release directory as I need it to be able to cd into it and run composer (and run a few other items, too). I currently have;
namespace :deploy do
namespace :symlink do
desc 'Run composer'
task :runcomposer do
on roles :all do
execute "cd '#{current_release}' && composer install"
execute "cd '#{current_release}' && ln -s /sites/shared/index.php index.php"
end
end
before :release, :runcomposer
end
end
The {current_release} variable doesn't seem to exist at this point (which is weird as the directory where the git pull is run has definitely been created within the /releases/ directory (with the appropriate timestamp) but I get 'undefined local variable or method "current_release"'
Is there a way I can determine this new release directory before the 'current' symlink is pointed at it? Thank you so much in advance.
Use composer extension
# Capfile
require 'capistrano/composer'
And by default there will be two tasks planned
before 'deploy:updated', 'composer:install'
before 'deploy:reverted', 'composer:install'
Removing one of the default tasks
Rake::Task['deploy:reverted'].prerequisites.delete('composer:install')
Read more on the official doc page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With