#!/bin/bash

set -o errexit -o nounset

if [ $TRAVIS_BRANCH = "8.0" ] && [ $TRAVIS_PULL_REQUEST = false ]; then
  cd ${TRAVIS_BUILD_DIR}
  rev=$(git rev-parse --short HEAD)

  cd ${HOME}/doc
  git init
  git config user.name "Guewen Baconnier"
  git config user.email "guewen.baconnier@camptocamp.com"
  git remote add upstream https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
  git fetch upstream
  git reset upstream/gh-pages

  echo "odoo-connector.com" > CNAME
  touch .nojekyll

  touch .
  git add -A .
  git commit -m"rebuild pages at ${rev}"

  git push -q upstream HEAD:gh-pages
fi
