From 8fa2f091786eb75dc86117461e6a0b819c40f234 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Tue, 15 Aug 2023 11:18:40 -0400 Subject: [PATCH] jjb: efficios-www: move to deb12 builders Change-Id: I39043ae45b5645ac798dce6184812418fe9687d1 Signed-off-by: Michael Jeanson --- jobs/efficios-www.yaml | 27 +++++++++++------------ scripts/efficios-www/deploy.sh | 39 +++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/jobs/efficios-www.yaml b/jobs/efficios-www.yaml index 19cd30a..f4ab347 100644 --- a/jobs/efficios-www.yaml +++ b/jobs/efficios-www.yaml @@ -2,7 +2,7 @@ name: efficios-www project-type: freestyle defaults: global - node: amd64-rootnode-jammy + node: amd64-rootnode description: | This job is responsible for updating the efficios website. @@ -21,6 +21,7 @@ - file: credential-id: d023f830-9ab0-409f-b977-8cd0e1944dd5 variable: HOST_PUBLIC_KEYS + properties: - build-discarder: num-to-keep: 5 @@ -28,14 +29,25 @@ triggers: - pollscm: cron: "@hourly" + builders: - shell: !include-raw: scripts/efficios-www/deploy.sh scm: - - efficios-www + - git: + url: git@git.internal.efficios.com:efficios/efficios-www.git + credentials-id: f3c907b6-7485-49e1-afe1-4df24fac4ca1 + basedir: ./ + skip-tag: true + branches: + - master publishers: + - archive: + artifacts: 'site/**,prod/**' + follow-symlinks: true + allow-empty: false - ircbot: strategy: statechange-only message-type: summary @@ -62,14 +74,3 @@ matrix-trigger: only-parent send-to: - recipients - -- scm: - name: efficios-www - scm: - - git: - url: git@git.internal.efficios.com:efficios/efficios-www.git - credentials-id: f3c907b6-7485-49e1-afe1-4df24fac4ca1 - basedir: ./ - skip-tag: true - branches: - - master diff --git a/scripts/efficios-www/deploy.sh b/scripts/efficios-www/deploy.sh index f1c22d9..9f0fb13 100644 --- a/scripts/efficios-www/deploy.sh +++ b/scripts/efficios-www/deploy.sh @@ -18,42 +18,71 @@ 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 +} + # Add ssh key for deployment cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa +export DEBIAN_FRONTEND=noninteractive apt-get update -# Nodejs +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 # 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_FILE="$(mktemp -d)/linkchecker-out.csv" + +OUTPUT_DIR="$(mktemp -d)" +OUTPUT_FILE="${OUTPUT_DIR}/linkchecker-out.csv" + # linkchecker drops privileges to 'nobody' when run as root -chown nobody "$(dirname "${OUTPUT_FILE}")" +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_FILE}/.." + rm -rf "${OUTPUT_DIR}" sleep 5 # Let serve:prod stop exit 1 else - rm -rf "${OUTPUT_FILE}/.." + rm -rf "${OUTPUT_DIR}" kill "${SERVER_PID}" fi +print_header "Deploy website" grunt deploy:prod --verbose # EOF -- 2.34.1