Last active
November 25, 2015 19:44
-
-
Save jsoningram/0da8bbeee7a71cd87564 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Change 'www' and 'theme' to match your env | |
# Useage: ./deploy.sh <dir> <subdir> | |
# On completion, paste clipboard contents at prompt to go to repo | |
# 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="[email protected]:staging/offgrid1"; | |
elif [ "$dir" == "pre" ] && [ "$subdir" == "testing" ]; then | |
# Testing | |
git="[email protected]:production/offgrid1"; | |
elif [ "$dir" == "pro" ] && [ "$subdir" == "staging" ]; then | |
# Staging | |
git="[email protected]:staging/offgridweb"; | |
elif [ "$dir" == "pro" ] && [ "$subdir" == "production" ]; then | |
# Production | |
git="[email protected]: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) | |
deploy=deploy-`date +%F` | |
mv ~/$www/deploy ~/$www/$deploy | |
echo "The deploy dir has been renamed. You're set to push" | |
echo "cd ~/$www/$deploy/$dir/$subdir" | pbcopy | |
;; | |
no|n) | |
echo "Ok, All set to push" | |
echo "cd ~/$www/deploy/$dir/$subdir" | pbcopy | |
;; | |
*) | |
echo "Please answer yes or no" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment