Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. # Git Hook that will copy files into deploy-folder when you push into the master branch!
  4. # remember to make this executable "chmod +x post-receive"
  5.  
  6. # 1. read STDIN (Format: "from_commit to_commit branch_name")
  7. from, to, branch = ARGF.read.split " "
  8.  
  9. # 2. Only deploy if master branch was pushed
  10. if (branch =~ /master$/) == nil
  11. puts "Received branch #{branch}, not deploying."
  12. exit
  13. end
  14.  
  15. # 3. Copy files to deploy directory
  16. deploy_to_dir = File.expand_path('../deploy') # Change this to your deploy-folder path
  17. `GIT_WORK_TREE="#{deploy_to_dir}" git checkout -f master`
  18. puts "DEPLOY: master(#{to}) copied to '#{deploy_to_dir}'"
  19.  
  20. # 4. TODO: Deployment Tasks
  21. # i.e.: Run Puppet Apply, Restart Daemons,etc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement