Last active
August 29, 2015 14:10
-
-
Save opdavies/e4dc872da02c56748d09 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 | |
TARGET_REMOTE="origin" | |
TARGET_BRANCH="master" | |
DEPLOY_DIR="_deploy" | |
# Store the last commit message. | |
LOG=$(git log --oneline -1) | |
# Re-generate the site | |
sculpin generate --env prod | |
# Create and synchronise the deploy directory. | |
mkdir ${DEPLOY_DIR} | |
cp -R .git ${DEPLOY_DIR} | |
pushd ${DEPLOY_DIR} | |
git checkout -B ${TARGET_BRANCH} ${TARGET_REMOTE}/${TARGET_BRANCH} | |
popd | |
# Copy updated files. | |
cp -R output_prod/* ${DEPLOY_DIR} | |
# Copy static files. | |
if [ -d static-files ]; then | |
pushd static-files | |
find . -type f | cpio -pdmuv "../${DEPLOY_DIR}" | |
popd | |
fi | |
pushd ${DEPLOY_DIR} | |
git add . --all | |
git commit -m "${LOG}" | |
git push ${TARGET_REMOTE} ${TARGET_BRANCH} | |
popd | |
# Delete the deploy directory. | |
rm -rf ${DEPLOY_DIR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment