#!/usr/bin/env bash
# Wed 21 Sep 2016 13:08:05 CEST

source $(dirname ${0})/functions.sh

info=sphinx/.gitlab-ci.info

echo "repo=${CI_PROJECT_PATH}" > ${info}
echo "branch=${CI_BUILD_REF_NAME}" >> ${info}
echo "tag=${CI_BUILD_TAG}" >> ${info}
echo "build=${CI_BUILD_ID}" >> ${info}
echo "commit=${CI_BUILD_REF}" >> ${info}
echo "runner=${CI_RUNNER_DESCRIPTION}" >> ${info}

# folder for HEAD of master
if [[ $IS_MASTER == true ]]; then
  dav_upload_folder sphinx "$MASTER_UPLOAD_PATH"
fi

# upload to the tag folder if this build is tagged
if [[ -n $CI_BUILD_TAG ]]; then
  dav_upload_folder sphinx "$TAG_UPLOAD_PATH"
fi

# upload to the stable folder if this build is tagged and on master
if [[ -n $CI_BUILD_TAG && $IS_MASTER == true ]]; then
  dav_upload_folder sphinx "$STABLE_UPLOAD_PATH"
fi
