test_remote_git_deployement.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. #hook/pre-receive
  3. #CONFIG
  4. echo "- - - - PRE-RECEIVE - - - -"
  5. REPO="sites/all/modules/features"
  6. echo $REPO
  7. #read oldrev newrev refname
  8. refname="refs/heads/sandbox"
  9. if [ $refname = "refs/heads/prod" ]; then
  10. BASE="public_html/base_d7"
  11. elif [ $refname = "refs/heads/sandbox" ]; then
  12. BASE="public_html/base_d7_sb"
  13. else
  14. BASE="none"
  15. fi
  16. echo $BASE
  17. if [ $BASE != "none" ]; then
  18. echo "===== UPDATE REPOSITORY | $refname ====="
  19. unset GIT_DIR
  20. cd ~
  21. cd $BASE
  22. cd $REPO
  23. git add .
  24. git commit -m "Auto Commit"
  25. echo "====== OK ====="
  26. else
  27. echo "Warning Commit not deployed, please use sandbox or prod branch"
  28. fi
  29. #!/bin/bash
  30. #hook/post-receive
  31. #CONFIG
  32. echo "- - - - POST-RECEIVE - - - - "
  33. REPO="sites/all/modules/features"
  34. echo $REPO
  35. #read oldrev newrev refname
  36. refname="refs/heads/prod"
  37. if [ $refname = "refs/heads/prod" ]; then
  38. BASE="public_html/base_d7"
  39. elif [ $refname = "refs/heads/sandbox" ]; then
  40. BASE="public_html/base_d7_sb"
  41. else
  42. BASE="none"
  43. fi
  44. echo $BASE
  45. if [ $BASE != "none" ]; then
  46. echo "===== DEPLOYING APP | $refname ====="
  47. unset GIT_DIR
  48. cd ~
  49. cd $BASE
  50. cd $REPO
  51. if [ $refname = "refs/heads/prod" ]; then
  52. git pull --ff-only origin prod
  53. elif [ $refname = "refs/heads/sandbox" ]; then
  54. git pull --ff-only origin sandbox
  55. fi
  56. echo $?
  57. echo "====== OK ====="
  58. else
  59. echo "Warning : Commit not deployed, please use prod branch"
  60. fi