Ensure BUILD_DIR is defined and used

This commit is contained in:
Oliver Davies 2017-07-25 18:00:13 +01:00
parent 39cd1525f0
commit ecc9308ccb

View file

@ -5,29 +5,27 @@ set -e
SITE_ENV="prod" SITE_ENV="prod"
REPO=`git config remote.origin.url` REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD` BUILD_DIR="_deploy"
SOURCE_BRANCH="source"
TARGET_BRANCH="master"
BUILD_DIR=".build"
# Prepare the build directory. # Prepare the build directory.
git clone $REPO $BUILD_DIR git clone $REPO $BUILD_DIR
pushd $BUILD_DIR pushd $BUILD_DIR
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH git checkout master || git checkout --orphan master
popd popd
rm -rf ${BUILD_DIR}/**/* || exit 0 rm -rf ${BUILD_DIR}/**/* || exit 0
# Re-generate the site. # Re-generate the site.
npm run prod npm run prod
vendor/bin/sculpin generate --no-interaction --clean --env=${SITE_ENV} vendor/bin/sculpin generate --no-interaction --clean --env=prod
touch output_${SITE_ENV}/.nojekyll touch output_prod/.nojekyll
# Add, commit and push the changes. # Add, commit and push the changes.
mv output_${SITE_ENV}/* $BUILD_DIR mv output_prod/* $BUILD_DIR
pushd $BUILD_DIR pushd $BUILD_DIR
git add --all . echo "!/assets/css/
git commit -m "Re-generate site: $SHA" !/assets/images/
git push $SSH_REPO $TARGET_BRANCH !/assets/js/" > .gitignore
git add --all -f .
git commit -m "Re-generate site: `git rev-parse --verify HEAD`"
git push $SSH_REPO master
popd popd
rm -rf $BUILD_DIR