X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=scripts%2Fefficios-www%2Fdeploy.sh;h=389a3175f8020ecf05ec17313a53f937ef7ca57a;hb=247873aa5832b9bab44ea94c068f295f5e1a0d72;hp=7a9ef2230cdf1de489e607b4838a9143c0cb3a25;hpb=5b461c35e28ee2444813500e5b4ef9f47c4e3da0;p=lttng-ci.git diff --git a/scripts/efficios-www/deploy.sh b/scripts/efficios-www/deploy.sh index 7a9ef22..389a317 100644 --- a/scripts/efficios-www/deploy.sh +++ b/scripts/efficios-www/deploy.sh @@ -18,18 +18,74 @@ set -exu +print_header() { + set +x + + local message=" $1 " + local message_len + local padding_len + + message_len="${#message}" + padding_len=$(( (80 - (message_len)) / 2 )) + + printf '\n'; printf -- '#%.0s' {1..80}; printf '\n' + printf -- '-%.0s' {1..80}; printf '\n' + printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n' + printf -- '-%.0s' {1..80}; printf '\n' + printf -- '#%.0s' {1..80}; printf '\n\n' + + set -x +} + +# Fail early if not set +echo "Deploy target: ${DEPLOY_TARGET}" + # Add ssh key for deployment cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa -# Nodejs -apt-get install -y npm +export DEBIAN_FRONTEND=noninteractive +apt-get update + +print_header "Install web tooling dependencies" +apt-get install --no-install-recommends -y npm ./bootstrap-ubuntu.sh + +print_header "Install NPM stuff" npm install +print_header "Build website with grunt" grunt build:dev --verbose grunt deploy:pre --verbose grunt build:prod --verbose -grunt deploy:prod --verbose + +# Check for broken internal links +print_header "Check links" +apt-get install -y linkchecker +grunt connect:prod watch:prod & +SERVER_PID="${!}" +sleep 10 # While serve:prod starts up + +OUTPUT_DIR="$(mktemp -d)" +OUTPUT_FILE="${OUTPUT_DIR}/linkchecker-out.csv" + +# linkchecker drops privileges to 'nobody' when run as root +chown nobody "${OUTPUT_DIR}" + +# @Note: Only internal links are checked by default +if ! linkchecker -q -F "csv/utf-8/${OUTPUT_FILE}" http://localhost:10000/ ; then + echo "Linkchecker failed or found broken links" + cat "${OUTPUT_FILE}" + kill "${SERVER_PID}" + rm -rf "${OUTPUT_DIR}" + sleep 5 # Let serve:prod stop + exit 1 +else + rm -rf "${OUTPUT_DIR}" + kill "${SERVER_PID}" +fi + +print_header "Deploy website" +grunt "${DEPLOY_TARGET}" --verbose # EOF