diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39c8752311726bb160a9b88380fbb4baa5b037ca..275d86895931b86a25d7253c6b804f35e8f717ec 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -265,14 +265,20 @@ pages: cd ./doc && sphinx-build -b html -n --no-color -W --keep-going -T -j auto -d "$doctree" . "$out/$publish_as" ) } - build_branch main main - build_branch preview preview - build_branch master master - - # If the folder is empty, remove it to avoid emptying the documentation and stop here. - if rmdir "$out" &>/dev/null; then - exit 0 - fi + + function fail() { + if ! "$@"; then + # If one of the build phases failed, make sure we do not + # accidentally deploy a partial artifact (likely mostly empty) + # and exit with error + rm -r "$out" &>/dev/null + exit 1 + fi + } + + fail build_branch main main + fail build_branch preview preview + fail build_branch master master # TODO: For now the release branch doc won't build as it lacks some necessary fixes # build_branch release release