#!/usr/bin/env bash
# Will deploy the documentation website on gh-pages when new commits on master
# Only if it detects changes in ./docs folder
# Note that this will be triggered even for PR targeting master
set -x

if ./scripts/travis/is-pr; then
  echo "✘ Documentation is not deployed for pull requests";
  exit 0
fi

if ! ./scripts/travis/on-master; then
  echo "✘ Documentation is only deployed on the master branch";
  exit 0
fi

if ! ./scripts/travis/changes-in-docs-since-master; then
  echo "✘ Documentation is not deployed if there are no changes in ./docs";
  exit 0
fi

cd ./docs || exit 1
yarn install
yarn run deploy
