Skip to content

Instantly share code, notes, and snippets.

@dblencowe
Created May 8, 2016 09:33
Show Gist options
  • Save dblencowe/e7063693621c52c4f6b45bdaf754c4b9 to your computer and use it in GitHub Desktop.
Save dblencowe/e7063693621c52c4f6b45bdaf754c4b9 to your computer and use it in GitHub Desktop.
Deploy Bedrock sites to a standard Wordpress install using Git and Continuous Integration
#!/usr/bin/env bash
###
# Check that we have the correct working directory.
###
if [ ! -d "web" ]
then
echo "Please run this script from the main web directory."
exit
fi
###
# Stop if there are uncommitted changes
###
if [[ -n $(git status -s) ]]
then
echo "Please review and commit your changes before continuing."
exit
fi
git checkout -b deploy --force
git rm --cached -r .
###
# Create a temporary wp-content directory to match the original WP structure
# Then move the items we want in our repo over
###
if [ ! -d "wp-content" ]
then
mkdir wp-content
fi
cp -rf web/app/{themes,plugins} ./wp-content/
###
# Commit new structure into git, and push to remote.
###
git add wp-content
git commit -am "Deploy build from: $(git log -1 HEAD --pretty=format:%s)$(git rev-parse --short HEAD 2> /dev/null | sed "s/\(.*\)/@\1/")"
echo "Pushing to repository..."
git push -f -u origin deploy
git checkout master --force
git branch -D deploy
rm -rf wp-content
echo "Successfully deployed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment