Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running task before deploy:symlink:shared capistrano 3

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.

like image 208
RichardTape Avatar asked Nov 01 '22 19:11

RichardTape


1 Answers

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.

like image 159
Jekis Avatar answered Nov 15 '22 06:11

Jekis