Class: Docker::PushBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/scripts/docker/push_branch.rb

Instance Method Summary collapse

Instance Method Details

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/scripts/docker/push_branch.rb', line 3

def run
  env_require("DOCKER_IMAGE")

  # set image tag if it hasnt been set
  # Default: current git hash
  env_check("IMAGE_TAG", `git rev-parse HEAD`.strip)

  branch = `git rev-parse --abbrev-ref HEAD`.strip

  # tag image
  command("docker tag \"$DOCKER_IMAGE:$IMAGE_TAG\" \"$DOCKER_IMAGE:#{branch}\"")

  # push docker image
  command("docker push \"$DOCKER_IMAGE:#{branch}\"")
end