Skip to content

Commit

Permalink
Add role filtering (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrodzicki authored and Nyholm committed Mar 6, 2018
1 parent 29fbe4f commit d5d659c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ set :linked_dirs, ["var/logs"]
# Set correct permissions between releases, this is turned off by default
set :file_permissions_paths, ["var"]
set :permission_method, false

# Role filtering
set :symfony_roles, :all
```

#### Using this plugin with the old Symfony 2 directory structure and SensioDistributionBundle <= 4
Expand Down
3 changes: 3 additions & 0 deletions lib/capistrano/symfony/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
set :file_permissions_paths, -> { fetch(:symfony_directory_structure) == 2 ? [fetch(:log_path), fetch(:cache_path)] : [fetch(:var_path)] }
# Method used to set permissions (:chmod, :acl, or :chown)
set :permission_method, false

# Role filtering
set :symfony_roles, :all
14 changes: 7 additions & 7 deletions lib/capistrano/tasks/symfony.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace :symfony do
# ask only runs if argument is not provided
ask(:cmd, "cache:clear")
command = args[:command] || fetch(:cmd)
role = args[:role] || :all
role = args[:role] || fetch(:symfony_roles)
params = args[:params] || ''

on release_roles(role) do
Expand All @@ -21,14 +21,14 @@ namespace :symfony do
namespace :cache do
desc "Run app/console cache:clear for the #{fetch(:symfony_env)} environment"
task :clear do
on release_roles(:all) do
on release_roles(fetch(:symfony_deploy_roles)) do
symfony_console "cache:clear"
end
end

desc "Run app/console cache:warmup for the #{fetch(:symfony_env)} environment"
task :warmup do
on release_roles(:all) do
on release_roles(fetch(:symfony_deploy_roles)) do
symfony_console "cache:warmup"
end
end
Expand All @@ -37,7 +37,7 @@ namespace :symfony do
namespace :assets do
desc "Install assets"
task :install do
on release_roles(:all) do
on release_roles(fetch(:symfony_deploy_roles)) do
within release_path do
symfony_console "assets:install", fetch(:assets_install_path) + ' ' + fetch(:assets_install_flags)
end
Expand All @@ -47,7 +47,7 @@ namespace :symfony do

desc "Create the cache directory"
task :create_cache_dir do
on release_roles :all do
on release_roles(fetch(:symfony_deploy_roles)) do
within release_path do
if test "[ -d #{symfony_cache_path} ]"
execute :rm, "-rf", symfony_cache_path
Expand All @@ -67,7 +67,7 @@ namespace :symfony do
desc "Clear non production controllers"
task :clear_controllers do
next unless any? :controllers_to_clear
on release_roles :all do
on release_roles(fetch(:symfony_deploy_roles)) do
within symfony_web_path do
execute :rm, "-f", *fetch(:controllers_to_clear)
end
Expand All @@ -76,7 +76,7 @@ namespace :symfony do

desc "Build the bootstrap file"
task :build_bootstrap do
on release_roles :all do
on release_roles(fetch(:symfony_deploy_roles)) do
within release_path do
if fetch(:symfony_directory_structure) == 2
execute :php, build_bootstrap_path, fetch(:app_path)
Expand Down

0 comments on commit d5d659c

Please sign in to comment.