Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Useage: ./deploy.sh <dir> <subdir>
- # Set variables to match your environment
- www="Q4/Stash"
- theme="offgrid"
- # Store passed arguments
- dir=$1
- subdir=$2
- # Capitalize first leter of $subdir for use in commit message
- commitdir="$(tr '[:lower:]' '[:upper:]' <<< ${subdir:0:1})${subdir:1}"
- # Set $git based on passed arguments
- if [ "$dir" == "pre" ] && [ "$subdir" == "development" ]; then
- # Development
- git="git@git.wpengine.com:staging/offgrid1";
- elif [ "$dir" == "pre" ] && [ "$subdir" == "testing" ]; then
- # Testing
- git="git@git.wpengine.com:production/offgrid1";
- elif [ "$dir" == "pro" ] && [ "$subdir" == "staging" ]; then
- # Staging
- git="git@git.wpengine.com:staging/offgridweb";
- elif [ "$dir" == "pro" ] && [ "$subdir" == "production" ]; then
- # Production
- git="git@git.wpengine.com:production/offgridweb";
- fi
- # Create directory sructure
- mkdir -p ~/$www/deploy/{pre/{development,testing},pro/{production,staging}}
- # Run through the various steps
- cd ~/$www/deploy/$dir/$subdir
- git clone $git .
- rm -rf ~/$www/deploy/$dir/$subdir/wp-content
- cp -rf ~/$www/$theme/hgv_data/sites/hhvm/wp-content .
- rm wp-content/.gitignore
- vim wp-content/themes/$theme/.gitignore
- find ./wp-content -type d -name ".git" -exec rm -rf {} \;
- if [ "$dir" == "pro" ] && [ "$subdir" == "production" ]; then
- vim wp-content/.env
- fi
- git status
- git diff
- git add -A
- git commit -m "Deploy to $commitdir: Manual"
- # Answering yes will append "deploy" with today's date
- echo "Do you want to rename the deploy dir with today's date?"
- read a
- case $a in
- yes|y)
- mv ~/$www/deploy ~/$www/deploy-`date +%F`
- echo "The deploy dir has been renamed. You're set to push"
- ;;
- no|n)
- echo "Ok, All set to push"
- ;;
- *)
- echo "Please answer yes or no"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement