Skip to content
Snippets Groups Projects
Commit ca33177a authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Use array variable containig doc uploads

parent 5813e43a
Branches
No related tags found
No related merge requests found
#!/usr/bin/env bash #!/usr/bin/env bash
# Thu 22 Sep 2016 18:23:57 CEST # Thu 22 Sep 2016 18:23:57 CEST
# unset vars exported in before_docs.sh
unset IS_MASTER
unset MASTER_UPLOAD_PATH
unset TAG_UPLOAD_PATH
unset STABLE_UPLOAD_PATH
...@@ -3,52 +3,7 @@ ...@@ -3,52 +3,7 @@
source $(dirname ${0})/functions.sh source $(dirname ${0})/functions.sh
# decide whether this is master # Deletes all existing dav folders that will be overwritten
# assume it's being ran on master by default for k in "${DOC_UPLOADS[@]}"; do
IS_MASTER=true dav_delete "${k}"
# if its a tag build, it might not be master done
if [[ -n $CI_BUILD_TAG ]]; then
IS_MASTER=false
# fetch repo & check if tag came from master
git fetch origin
for p in $(git branch -a --quiet --contains tags/"$CI_BUILD_TAG"); do
[[ $p == 'remotes/origin/master' ]] && IS_MASTER=true
done
fi
# prefix differs between private & public repos
if [[ "${VISIBILITY}" == "public" ]]; then
DOCS_SERVER_PREFIX="public-upload/$CI_PROJECT_PATH/docs"
else
DOCS_SERVER_PREFIX="private-upload/$CI_PROJECT_PATH/docs"
fi
# define possible upload paths
# folder for master branch
MASTER_UPLOAD_PATH="$DOCS_SERVER_PREFIX/master/"
# folder for a tag
TAG_UPLOAD_PATH="$DOCS_SERVER_PREFIX/$CI_BUILD_TAG/"
# folder for new stable version
STABLE_UPLOAD_PATH="$DOCS_SERVER_PREFIX/stable/"
# rm already existing folders if necessary
# folder for HEAD of master
if [[ $IS_MASTER == true ]]; then
dav_delete "$MASTER_UPLOAD_PATH"
fi
# upload to the tag folder if this build is tagged
if [[ -n $CI_BUILD_TAG ]]; then
dav_delete "$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_delete "$STABLE_UPLOAD_PATH"
fi
# export vars for docs script to use
export_env IS_MASTER
export_env MASTER_UPLOAD_PATH
export_env TAG_UPLOAD_PATH
export_env STABLE_UPLOAD_PATH
...@@ -3,31 +3,7 @@ ...@@ -3,31 +3,7 @@
source $(dirname ${0})/functions.sh source $(dirname ${0})/functions.sh
check_env IS_MASTER # Deletes all existing dav folders that will be overwritten
check_env MASTER_UPLOAD_PATH for k in "${DOC_UPLOADS[@]}"; do
check_env TAG_UPLOAD_PATH dav_upload_folder "${k}"
check_env STABLE_UPLOAD_PATH done
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment