Method: Docker.deploy_stages

Defined in:
lib/docker.rb

.deploy_stagesObject



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
# File 'lib/docker.rb', line 46

def deploy_stages
  candidates = Dir['deploy-to*']
  if candidates.size == 1
    script = candidates.first
    if File.executable?(script)
      branch = ENV['GIT_BRANCH'] ||
        `git symbolic-ref --short -q HEAD`.strip
      return `./#{script} #{branch}`.strip.split(',')
    else
      error!(
        RuntimeError.new(
          %(Deploy-to script: "#{script}" must be executable! (e.g. chmod +x #{script}))
        ),
        "determining stage to deploy to"
      )
    end
  else
    error!(
      RuntimeError.new(
        "There must be a deploy-to* script " +
        "(e.g. deploy-to.{rb|sh|js}): #{candidates.size} found"
      ),
      "determining stage to deploy to"
    )
  end
end