Method: Bard::CLI#deploy

Defined in:
lib/bard.rb

#deploy(branch = Git.current_branch) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/bard.rb', line 36

def deploy branch=Git.current_branch
  if branch == "master"
    run_crucial "git push origin master:master"
    invoke :ci unless options["skip-ci"]

  else
    run_crucial "git fetch origin master:master"

    if not Git.fast_forward_merge? "origin/master", branch
      puts "The master branch has advanced. Attempting rebase..."
      run_crucial "git rebase origin/master"
    end

    run_crucial "git push -f origin #{branch}:#{branch}"

    invoke :ci unless options["skip-ci"]

    run_crucial "git push origin #{branch}:master"
    run_crucial "git fetch origin master:master"
  end

  run_crucial "cap _2.5.10_ deploy", options.verbose?

  puts green("Deploy Succeeded")

  if branch != "master"
    puts "Deleting branch: #{branch}"
    run_crucial "git push --delete origin #{branch}"

    case Git.current_branch
    when branch
      run_crucial "git checkout master"
      run_crucial "git branch -d #{branch}"
    when "master"
      run_crucial "git branch -d #{branch}"
    else
      run_crucial "git branch -D #{branch}"
    end
  end

  unless system("cap _2.5.10_ ping ROLES=production >/dev/null 2>&1")
    puts red("Production is now down!")
  end
end