Sha256: ef384ebed112224ad6a53fc00e8ec392ac4d9a3d77869656a6a725b1b998e48a

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'dk/task'
require "dk-abdeploy/constants"
require 'dk-abdeploy/validate'

module Dk::ABDeploy

  class Setup
    include Dk::Task

    desc "(dk-abdeploy) create the dirs and clone the repos for the A/B deploy scheme"

    before Validate

    ssh_hosts SSH_HOSTS_GROUP_NAME

    def run!
      # make the expected dirs if not already made
      mkdirs = [
        params[ROOT_PARAM_NAME].to_s,
        params[SHARED_DIR_PARAM_NAME],
        params[RELEASES_DIR_PARAM_NAME],
        params[RELEASE_A_DIR_PARAM_NAME],
        params[RELEASE_B_DIR_PARAM_NAME]
      ]
      ssh! "mkdir -p #{mkdirs.join(' ')}"

      # clone the A/B release repos if not already cloned
      ssh! clone_cmd_str(params[REPO_PARAM_NAME], params[RELEASE_A_DIR_PARAM_NAME])
      ssh! clone_cmd_str(params[REPO_PARAM_NAME], params[RELEASE_B_DIR_PARAM_NAME])
    end

    private

    def clone_cmd_str(repo, release_dir)
      "if [ -d #{release_dir}/.git ]; " \
      "then echo 'repo already cloned'; " \
      "else git clone -q  #{repo} #{release_dir}; " \
      "fi"
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dk-abdeploy-0.1.0 lib/dk-abdeploy/setup.rb