oliverdavies.uk/publish.sh

31 lines
724 B
Bash
Raw Normal View History

2017-07-10 22:12:20 +00:00
#!/usr/bin/env bash
2017-07-25 00:35:37 +00:00
set -e
2017-07-10 22:12:20 +00:00
2017-07-24 17:15:56 +00:00
SITE_ENV="prod"
2017-07-24 16:16:20 +00:00
REPO=`git config remote.origin.url`
SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:}
2017-07-25 18:01:17 +00:00
SHA=`git rev-parse --verify HEAD`
BUILD_DIR="_deploy"
2017-07-24 16:16:20 +00:00
2017-07-25 00:35:37 +00:00
# Prepare the build directory.
git clone $REPO $BUILD_DIR
2017-07-25 16:57:18 +00:00
pushd $BUILD_DIR
2017-07-25 17:00:13 +00:00
git checkout master || git checkout --orphan master
2017-07-25 00:35:37 +00:00
popd
2017-07-25 01:09:32 +00:00
rm -rf ${BUILD_DIR}/**/* || exit 0
2017-07-24 23:47:00 +00:00
2017-07-25 00:35:37 +00:00
# Re-generate the site.
2017-08-03 00:14:30 +00:00
node_modules/.bin/gulp --production
2017-07-25 17:00:13 +00:00
vendor/bin/sculpin generate --no-interaction --clean --env=prod
touch output_prod/.nojekyll
2017-07-24 19:06:06 +00:00
2017-07-10 22:12:20 +00:00
# Add, commit and push the changes.
2017-07-25 16:57:18 +00:00
pushd $BUILD_DIR
2017-07-25 17:47:47 +00:00
mv ../output_prod/* .
2017-07-25 17:50:33 +00:00
git config --local user.email oliver@oliverdavies.uk
2017-07-25 17:46:44 +00:00
git add -A .
2017-07-25 18:01:17 +00:00
git commit -m "Re-generate site: $SHA"
2017-07-25 17:00:13 +00:00
git push $SSH_REPO master
2017-07-25 00:35:37 +00:00
popd