Advertisement
Guest User

Untitled

a guest
Nov 24th, 2015
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #!/bin/bash
  2. # Useage: ./deploy.sh <dir> <subdir>
  3.  
  4. # Set variables to match your environment
  5. www="Q4/Stash"
  6. theme="offgrid"
  7.  
  8. # Store passed arguments
  9. dir=$1
  10. subdir=$2
  11.  
  12. # Capitalize first leter of $subdir for use in commit message
  13. commitdir="$(tr '[:lower:]' '[:upper:]' <<< ${subdir:0:1})${subdir:1}"
  14.  
  15. # Set $git based on passed arguments
  16. if [ "$dir" == "pre" ] && [ "$subdir" == "development" ]; then
  17. # Development
  18. git="git@git.wpengine.com:staging/offgrid1";
  19. elif [ "$dir" == "pre" ] && [ "$subdir" == "testing" ]; then
  20. # Testing
  21. git="git@git.wpengine.com:production/offgrid1";
  22. elif [ "$dir" == "pro" ] && [ "$subdir" == "staging" ]; then
  23. # Staging
  24. git="git@git.wpengine.com:staging/offgridweb";
  25. elif [ "$dir" == "pro" ] && [ "$subdir" == "production" ]; then
  26. # Production
  27. git="git@git.wpengine.com:production/offgridweb";
  28. fi
  29.  
  30. # Create directory sructure
  31. mkdir -p ~/$www/deploy/{pre/{development,testing},pro/{production,staging}}
  32.  
  33. # Run through the various steps
  34. cd ~/$www/deploy/$dir/$subdir
  35. git clone $git .
  36.  
  37. rm -rf ~/$www/deploy/$dir/$subdir/wp-content
  38. cp -rf ~/$www/$theme/hgv_data/sites/hhvm/wp-content .
  39. rm wp-content/.gitignore
  40.  
  41. vim wp-content/themes/$theme/.gitignore
  42.  
  43. find ./wp-content -type d -name ".git" -exec rm -rf {} \;
  44.  
  45. if [ "$dir" == "pro" ] && [ "$subdir" == "production" ]; then
  46. vim wp-content/.env
  47. fi
  48.  
  49. git status
  50. git diff
  51.  
  52. git add -A
  53. git commit -m "Deploy to $commitdir: Manual"
  54.  
  55. # Answering yes will append "deploy" with today's date
  56. echo "Do you want to rename the deploy dir with today's date?"
  57. read a
  58. case $a in
  59. yes|y)
  60. mv ~/$www/deploy ~/$www/deploy-`date +%F`
  61. echo "The deploy dir has been renamed. You're set to push"
  62. ;;
  63. no|n)
  64. echo "Ok, All set to push"
  65. ;;
  66. *)
  67. echo "Please answer yes or no"
  68. ;;
  69. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement