Upload documentation to GitHub only if generation succeeded

As suggested by Radu in #584, this adds a protection from failures in documentation generation. If it failed, then the script does not upload anything to GitHub and exit with error code so that Travis has indication of failure.