module AppRb::Util::Build def self.build(user, host, repo, ssh_key, target, registry, image_name, pre_build_cmds = []) AppRb::Util.do_it "ssh #{user}@#{host} bash < \\$tmpfile echo 'exec /usr/bin/ssh -o StrictHostKeyChecking=no -i #{ssh_key} \"\\$@\"' >> \\$tmpfile chmod +x \\$tmpfile export GIT_SSH=\\$tmpfile if [ -d #{repo_cache(repo)} ]; then echo update cache... cd #{repo_cache(repo)} git checkout . && git clean -dfx && git checkout master && git pull git branch | grep -v master | xargs -r git branch -D else echo clone... git clone git@github.com:#{repo} #{repo_cache(repo)} && cd #{repo_cache(repo)} fi git checkout #{target} rm \\$tmpfile\nEOF" hash = AppRb::Util.just_cmd("ssh #{user}@#{host} 'cd #{repo_cache(repo)} && git rev-parse HEAD'") tags = AppRb::Util::Registry.tags_list(registry, image_name) puts "hash: #{hash}" puts "tags: #{tags.inspect}" unless tags.index(hash) puts AppRb::Util.blue("+++ BUILD image") AppRb::Util.do_it "ssh #{user}@#{host} bash <