Module: Bard::CLI::Stage

Defined in:
lib/bard/cli/stage.rb

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bard/cli/stage.rb', line 5

def self.included mod
  mod.class_eval do

    desc "stage [branch=HEAD]", "pushes current branch, and stages it"
    def stage branch=Bard::Git.current_branch
      unless config.servers.key?(:production)
        raise Thor::Error.new("`bard stage` is disabled until a production server is defined. Until then, please use `bard deploy` to deploy to the staging server.")
      end

      run! "git push -u origin #{branch}", verbose: true
      config[:staging].run! "git fetch && git checkout -f origin/#{branch} && bin/setup"
      puts green("Stage Succeeded")

      ping :staging
    rescue Bard::Command::Error => e
      puts red("!!! ") + "Running command failed: #{yellow(e.message)}"
      exit 1
    end

  end
end