t3labcom/capistrano-typo3

View on GitHub
lib/capistrano/tasks/typo3.cap

Summary

Maintainability
Test Coverage
# vim: ft=ruby:sts=2:expandtab

#----- DEFAULT SETTINGS, OVERRIDE WHEN NEEDED

set :debug, 0
set :git_no_cache, 0

set :restart_webserver, "sudo /etc/init.d/apache2 restart"
set :rake_mysql_exec_dir, "/usr/bin"

set :t3_post_deployment_commands, []
set :t3_db_sync_ignore_tables, []
set :t3_ts_constants, []

set :typo3_v6_local_conf_path, File.join('current','dummy','typo3conf','LocalConfiguration.php')
set :http_protocol, 'http'

namespace :typo3 do

  desc "Setup a new production environment. Don't sync content from old production"
  task :setup_new_stage_no_sync do
    invoke 'typo3:helper:rm_deploy_to'
    invoke 'deploy'

    invoke 'typo3:helper:setup_shared_typo3_dirs' unless fetch(:t3_skip_setup_shared_typo3_dirs)
    invoke 'typo3:helper:update_localconf' unless fetch(:t3_skip_update_localconf)
    invoke 'typo3:helper:write_tsconstants' unless fetch(:t3_skip_write_tsconstants)
    invoke 'typo3:helper:current_relative_symlink' unless fetch(:t3_skip_current_relative_symlink)
    invoke 'typo3:helper:restart_webserver' unless fetch(:t3_skip_restart_webserver)

    invoke 'typo3:helper:execute_post_deployment_commands'

    print "environment has been setup, you do need to sync content from old production"
  end

  desc "Setup a new staged typo3 environment when a it's already in model"
  task :setup_new_stage_sync do

    invoke 'typo3:helper:rm_deploy_to'
    invoke 'deploy'
    invoke 'typo3:helper:setup_shared_typo3_dirs' unless fetch(:t3_skip_setup_shared_typo3_dirs)

    invoke 'typo3:content:sync_files_from_production'
    invoke 'typo3:content:sync_db_from_production'
    invoke 'typo3:content:flush_cache_in_db'
    invoke 'typo3:helper:update_localconf' unless fetch(:t3_skip_update_localconf)
    invoke 'typo3:helper:write_tsconstants' unless fetch(:t3_skip_write_tsconstants)
    invoke 'typo3:helper:current_relative_symlink' unless fetch(:t3_skip_current_relative_symlink)
    invoke 'typo3:helper:restart_webserver' unless fetch(:t3_skip_restart_webserver)
    invoke 'typo3:helper:execute_post_deployment_commands'
  end

  desc "sync db & files and then deploy. Typically for Continuous Integration"
  task :sync_n_deploy do
    invoke 'deploy'
    invoke 'typo3:content:sync_files_from_production'
    invoke 'typo3:content:sync_db_from_production'
    invoke 'typo3:content:flush_cache_in_db'
    invoke 'typo3:helper:update_localconf' unless fetch(:t3_skip_update_localconf)
    invoke 'typo3:helper:write_tsconstants' unless fetch(:t3_skip_write_tsconstants)
    invoke 'typo3:helper:current_relative_symlink' unless fetch(:t3_skip_current_relative_symlink)
    invoke 'typo3:helper:restart_webserver' unless fetch(:t3_skip_restart_webserver)
    invoke 'typo3:helper:execute_post_deployment_commands'
  end

  desc "deploy the typo3 way"
  task :deploy do
    invoke 'deploy'
    invoke 'typo3:helper:update_localconf' unless fetch(:t3_skip_update_localconf)
    invoke 'typo3:helper:write_tsconstants' unless fetch(:t3_skip_write_tsconstants)
    invoke 'typo3:helper:current_relative_symlink' unless fetch(:t3_skip_current_relative_symlink)
    invoke 'typo3:helper:restart_webserver' unless fetch(:t3_skip_restart_webserver)
    invoke 'typo3:helper:execute_post_deployment_commands'
  end

  desc "Make db & files in env. identical to production"
  task :sync_from_production do
    invoke 'typo3:content:sync_files_from_production'
    invoke 'typo3:content:sync_db_from_production'
    invoke 'typo3:content:flush_cache_in_db'
  end

end