Giter VIP home page Giter VIP logo

capistrano-wearerequired's Introduction

Capistrano::Wearerequired · Gem Version

Capistrano::Wearerequired is a collection of recipes and tasks specialized on WordPress deployment.

Installation

  1. Add this line to your application's Gemfile to install the latest stable version:

    gem 'capistrano-wearerequired', '~> 2.0'
  2. Execute:

    $ bundle
    
  3. Require the library in your application's Capfile:

    require 'capistrano/wearerequired'

Usage

New Messaging Elements for Slackistrano

The class SlackistranoMessagingElements allows to change the icon with an emoji or image URL and to define a custom username.

Example:

set :slackistrano, {
    klass: Capistrano::Wearerequired::SlackistranoMessagingElements,
    channel: '#your-channel',
    webhook: 'your-incoming-webhook-url',
    icon_emoji: ':ship:',
    username: 'deploybot'
}

Colors for Slackistrano

The class SlackistranoMessagingColors adds colors to the deploy messages posted to Slack. SlackistranoMessagingColors extends SlackistranoMessagingElements.

Example:

set :slackistrano, {
    klass: Capistrano::Wearerequired::SlackistranoMessagingColors,
    channel: '#your-channel',
    webhook: 'your-incoming-webhook-url'
}

image

Expanded Git Messaging for Slackistrano

The class SlackistranoExpandedGitMessaging adds a link to the current diff, the current revision and branch, the name of the deployer and suppresses update messages. SlackistranoExpandedGitMessaging extends SlackistranoMessagingColors.

Example:

set :slackistrano, {
    klass: Capistrano::Wearerequired::SlackistranoExpandedGitMessaging,
    channel: '#your-channel',
    webhook: 'your-incoming-webhook-url',
}

image

See Customizing the Messaging for more information.

Additional tasks

To delete all content from Composer's cache directories run:

cap staging composer:clear_cache

To clean up all old releases but the last run:

cap staging deploy:cleanup_all

To install WordPress translations set :wp_language and run:

set :wp_languages, [
	'de_DE',
	'it_IT
]

cap staging wordpress:install_translations

To update WordPress translations run:

cap staging wordpress: update_translations

To clear OPcache of your site set :wp_clear_opcache, true and run:

cap staging wordpress:clear_opcache

(Requires the WP-CLI Clear OPcache plugin.)

capistrano-wearerequired's People

Contributors

grappler avatar ocean90 avatar swissspidy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

soultank

capistrano-wearerequired's Issues

Rename project to capistrano-wearerequired

In preparation of making this gem public I'm proposing to rename it to capistrano-wearerequired. Why? The new name has one less character and no underscore. 🙈 The current tasks/recipes are specific to our company/workflow but are still generic enough to be useful for others.

I searched for similar names in the repo and found https://github.com/demonz/capistrano-demonz, https://github.com/augustash/capistrano-ash, or https://rubygems.org/gems/crossroads_capistrano.

Thoughts?

Update WP-CLI commands to install translations

Besides wp language core there are now wp language plugin and wp language theme commands to install translations. Those are available since WP-CLI 2.0.

We should add them as well to make sure we get all the translations for our projects, not just the core ones.

Performance: Don't loop over wp_languages when installing translations

fetch(:wp_languages).each do |language|
execute :wp, "language core install #{language} 2> /dev/null", raise_on_non_zero_exit: false
execute :wp, "plugin list --field=name | xargs -I % wp language plugin install % #{language} 2> /dev/null", raise_on_non_zero_exit: false
execute :wp, "theme list --field=name | xargs -I % wp language theme install % #{language} 2> /dev/null", raise_on_non_zero_exit: false
end

Instead we should pass them as a list to the install command to reduce the number of commands.

Should probably be changed once wp-cli/language-command#61 is fixed.

Update compatibility with Slackistrano

/usr/local/lib/ruby/gems/2.7.0/gems/slackistrano-3.8.4/lib/slackistrano/capistrano.rb:34: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call 
/usr/local/lib/ruby/gems/2.7.0/gems/capistrano-wearerequired-2.0.0/lib/capistrano/wearerequired/slackistrano_messaging_elements.rb:7: warning: The called method `initialize' is defined here

The current requirements allows to use this lib with 3.8.4 Slackistrano which has changed the constructor to a single argument.

3.1: https://github.com/phallstrom/slackistrano/blob/v3.1.0/lib/slackistrano/messaging/base.rb
3.8: https://github.com/phallstrom/slackistrano/blob/v3.8.4/lib/slackistrano/messaging/base.rb

Add task to clear Opcache

We use a task on Cyon to clear the cache.

# Opcache Reset
namespace :deploy do
  desc 'Create a temporary PHP file to clear the opcache.'
  task :clear_cache do
    on roles(:app) do
      within fetch(:release_path) do
        opcache_file = "#{fetch(:release_path)}/opcache_clear.php"
        execute :touch, "#{opcache_file}"
        execute :chmod, "-R 644 #{opcache_file}"
        execute :echo, "'<?php opcache_reset(); ?>' > #{opcache_file}"
        execute :curl, "-s -k #{fetch(:opcache_file_url)}"
        execute :rm, "-f #{opcache_file}"
      end
    end
  end
end
after 'deploy:finishing', 'deploy:clear_cache'

Add task to clear composer cache

We have had trouble in the past to due to some cache issue with composer. It would be cool to have a task that does it on all three servers when we run into a issue.

it would be even better if the command was bundle exec cap staging composer clear-cache

	desc 'Clear composer cache'
	task :composer_clear_cache do
		on roles(:app) do
			within fetch(:release_path) do
				execute "composer clear-cache"
			end
		end
	end

Skip Slack notifications when there's no config for it

Getting messages like this when not using Slack notifications for a project:

  WARN [slackistrano] You are using an outdated configuration that will be removed soon.

  WARN [slackistrano] Please upgrade soon! <https://github.com/phallstrom/slackistrano>

  WARN [slackistrano] Error notifying Slack!

  WARN [slackistrano]   Error: #<SocketError: Failed to open TCP connection to .slack.com:443 (getaddrinfo: nodename nor servname provided, or not known)>

If no Slackistrano config is provided, we shouldn't attempt to load and execute it in the first place.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.