deploy.rb 3.15 KB
set :application, 'msf-climate-hub'
set :repo_url, 'git@git.gotenzing.com:msf/msf-climate-hub.git'

# Branch options
# Prompts for the branch name (defaults to current branch)
#ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }

# Hardcodes branch to always be master
# This could be overridden in a stage config file
set :branch, :"master"
SSHKit.config.command_map[:composer] = "/usr/bin/php74 /home/tenzing_www/composer.phar"

set :keep_releases, 2
set :deploy_to, -> { "/var/www/html/production/#{fetch(:application)}" }

# Use :debug for more verbose output when troubleshooting
set :log_level, :info

# Put all shared files/directories here (e.g. uploads that need to go on the NFS drive)
set :linked_files, fetch(:linked_files, []).push('.env')
set :linked_dirs, fetch(:linked_dirs, []).push('wp-content/uploads', 'wp-content/storage', 'wp-content/languages',  'wp-content/cache')

namespace :deploy do
  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      # execute :service, :nginx, :reload
    end
  end
end

namespace :deploy do
  desc 'Sync servers'
  task :sync do
    on roles(:web), in: :sequence, wait: 5 do
      execute "cd '#{release_path}/'; rm -Rf .git/ "
        execute("si #{fetch(:application)}")
    end
  end
end

namespace :deploy do
  desc 'Sync servers'
  task :sync_again do
    on roles(:web), in: :sequence, wait: 5 do
      execute("si #{fetch(:application)}")
    end
  end
end


namespace :deploy do
  desc 'Install composer packages in msf-child theme'
  task :install_theme_packages do
    on roles(:web), in: :sequence, wait: 5 do
      execute "cd '#{release_path}/wp-content/themes/msf-child/';  /usr/bin/php74 /home/tenzing_www/composer.phar install --quiet"
    end
  end
end

namespace :deploy do
  desc 'Install composer packages in root'
  task :install_root_packages do
    on roles(:web), in: :sequence, wait: 5 do
      execute "cd '#{release_path}';  /usr/bin/php74 /home/tenzing_www/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader"
    end
  end
end


namespace :deploy do
  desc 'set file permissions'
  task :set_permissions do
    on roles(:web), in: :sequence, wait: 5 do
      execute "cd '#{release_path}/'; chmod -Rf 777  .htaccess"
    end
  end
end



# Override `git#create_release` to handle submodules
namespace :git do
  desc 'Copy repo to releases'
  task create_release: :'git:update' do
    on roles(:all) do
      with fetch(:git_environmental_variables) do
        within repo_path do
          execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
        end
      end
    end
  end
end




  




# The above update_option_paths task is not run by default
# Note that you need to have WP-CLI installed on your server
# Uncomment the following line to run it on deploys if needed
# after 'deploy:publishing', 'deploy:update_option_paths'

after 'deploy:updated', 'deploy:install_theme_packages'
after 'deploy:updated', 'deploy:install_root_packages'
after 'deploy:updated', 'deploy:sync'
after 'deploy:updated', 'deploy:set_permissions'
after 'deploy:finished', 'deploy:sync_again'