class ReleaseXing TMP_FOLDER_NAME = "_RENUO_RELEASE_TEMP_#{rand(100_000_000)}".freeze MOVE_TO_TMP_FOLDER = "mkdir -p #{TMP_FOLDER_NAME} && cd #{TMP_FOLDER_NAME}".freeze def run checkout_project cmd_in_folder 'git remote add -f renuo git@github.com:renuo/xing-campaign.git' cmd_in_folder 'git pull' cmd_in_folder 'git fetch renuo develop' cmd_in_folder 'git subtree pull --prefix public renuo develop --squash' cmd_in_folder 'git push' ensure cleanup end private def checkout_project system "#{MOVE_TO_TMP_FOLDER} && git clone git@gitlab.dc.xing.com:renuo-ag/wunsch-arbeitgeber.xing.com.git" end def cmd_in_folder(command) system "#{move_and_cd} && #{command}" end def move_and_cd "#{MOVE_TO_TMP_FOLDER} && cd wunsch-arbeitgeber.xing.com" end def cleanup system("rm -rf #{TMP_FOLDER_NAME}") end end