Skip to content

Commit

Permalink
Script for publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD committed Feb 16, 2016
1 parent f304f1a commit 7fda696
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
61 changes: 61 additions & 0 deletions _scripts/publish-to-github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#! /bin/bash
# Make sure the staging branch is in sync with its remote
git reset --hard origin/production

git clean -fdx

# Remove all generated files and directories
rake clean[all]

rake setup

# build site in prod profile
rake --trace gen[production]

rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: Rake script failed!"
exit $rc
fi

pushd _tmp
# clone beanvalidation.github.io in _tmp if not present
if [ ! -d "beanvalidation.github.io" ];
then
git clone --depth 1 git@github.com:beanvalidation/beanvalidation.github.io.git
rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: beanvalidation/beanvalidation.github.io cannot be cloned!"
exit $rc
fi
fi

cd beanvalidation.github.io
git fetch origin
git reset --hard origin/master

# copy site to git repo, commit and push
# we filter cache as in production we shouldn't need that data
rsync -av \
--delete \
--filter "- /cache" --exclude ".git" --exclude "latest-draft/spec" \
../../_site/ .

rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: Site sync failed!"
exit $rc
fi

git add -A .
if git commit -m "Publish generated site";
then
git push origin master;
rc=$?
fi
popd
if [[ $rc != 0 ]] ; then
echo "ERROR: Cannot push on site repository!"
exit $rc
fi

30 changes: 30 additions & 0 deletions _scripts/publish-to-staging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
# Make sure the staging branch is in sync with its remote
git reset --hard origin/staging
git clean -fdx

# Remove all generated files and directories
rake clean[all]

# Make sure there was no update to the used dependencies (if not, this is just a quick version check for Bundler)
rake setup
rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: Rake setup failed!"
exit $rc
fi

# Build the site using the staging profile and sync
rake --trace gen[staging]
rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: Site generation failed!"
exit $rc
fi

rsync --delete --exclude "latest-draft/spec" -avh _site/ ci.hibernate.org:/var/www/staging-beanvalidation.org
rc=$?
if [[ $rc != 0 ]] ; then
echo "ERROR: Site sync failed!"
exit $rc
fi

0 comments on commit 7fda696

Please sign in to comment.