Use different branches

This commit is contained in:
Oliver Davies 2017-07-25 00:47:00 +01:00
parent 2043556dc5
commit 2ec69b9614

View file

@ -6,27 +6,24 @@ 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` SHA=`git rev-parse --verify HEAD`
SOURCE_BRANCH="source"
TARGET_BRANCH="master" TARGET_BRANCH="master"
# Build front-end assets. # Build front-end assets.
npm run prod npm run prod
git config --local user.email "oliver@oliver@oliverdavies.uk"
# Remove the existing docs directory, build the site and create the new # Remove the existing docs directory, build the site and create the new
# docs directory. # docs directory.
rm -rf ./docs rm -rf ./docs
vendor/bin/sculpin generate --no-interaction --clean --env=${SITE_ENV} vendor/bin/sculpin generate --no-interaction --clean --env=${SITE_ENV}
touch output_${SITE_ENV}/.nojekyll touch output_${SITE_ENV}/.nojekyll
mv output_${SITE_ENV} docs
git config --local user.email "oliver@oliver@oliverdavies.uk"
if [ -z `git diff --exit-code` ]; then
echo "No changes on this push. Exiting."
exit 0
fi
# Add, commit and push the changes. # Add, commit and push the changes.
git checkout $TARGET_BRANCH cd output_${SITE_ENV}
git add --all docs mv ../.git .
git checkout $TARGET_BRANCH || git checkout --orphan $TARGET_BRANCH
git add --all .
git commit -m "Re-generate site. $SHA" git commit -m "Re-generate site. $SHA"
git push $SSH_REPO $TARGET_BRANCH git push $SSH_REPO $TARGET_BRANCH