Skip to content

Instantly share code, notes, and snippets.

@opdavies
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save opdavies/e4dc872da02c56748d09 to your computer and use it in GitHub Desktop.
Save opdavies/e4dc872da02c56748d09 to your computer and use it in GitHub Desktop.
#!/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