jjb: lttng-modules: fix typo 'mark_args' -> 'make_args'
[lttng-ci.git] / scripts / lttng-www / deploy.sh
CommitLineData
8a02037b
JR
1#!/bin/bash
2# shellcheck disable=SC2103
3#
4# Copyright (C) 2021 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19set -exu
20
8ae912ac
MJ
21print_header() {
22 set +x
23
24 local message=" $1 "
25 local message_len
26 local padding_len
27
28 message_len="${#message}"
29 padding_len=$(( (80 - (message_len)) / 2 ))
30
31 printf '\n'; printf -- '#%.0s' {1..80}; printf '\n'
32 printf -- '-%.0s' {1..80}; printf '\n'
33 printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n'
34 printf -- '-%.0s' {1..80}; printf '\n'
35 printf -- '#%.0s' {1..80}; printf '\n\n'
36
37 set -x
38}
39
8a02037b 40# Add ssh key for deployment
4c61f7a4 41cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts
8a02037b
JR
42cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa
43
44# lttng-www dependencies
3b6ded16 45export DPKG_FRONTEND=noninteractive
3b6ded16 46apt-get update
8ae912ac
MJ
47
48print_header "Install web tooling dependencies"
49apt-get install -y nodejs node-grunt-cli npm ruby-bundler ruby-dev python3-pip python3-venv
50
94706d66
MJ
51ruby -v
52
8ae912ac
MJ
53apt-get install -y xmlto doclifter linkchecker
54
55python3 -m venv build_venv
56# shellcheck disable=SC1091
57source build_venv/bin/activate
8a02037b 58
3b6ded16 59bundle config set --local path "vendor/bundle"
de518de8 60
8ae912ac 61./bootstrap-debian.sh
8a02037b 62
8ae912ac
MJ
63print_header "Build website with grunt"
64bundle exec grunt build:prod
ed870945 65
8ae912ac 66print_header "Check links"
ed870945
KS
67bundle exec grunt connect:prod watch:prod &
68SERVER_PID="${!}"
69sleep 10 # While serve:prod starts up
8ae912ac
MJ
70
71OUTPUT_DIR="$(mktemp -d)"
72OUTPUT_FILE="${OUTPUT_DIR}/linkchecker-out.csv"
73
74# linkchecker drops privileges to 'nobody' when run as root
75chown nobody "${OUTPUT_DIR}"
76
ed870945
KS
77# @Note: Only internal links are checked by default
78if ! linkchecker -q -F "csv/utf-8/${OUTPUT_FILE}" http://localhost:10000/ ; then
79 echo "Linkchecker failed or found broken links"
80 cat "${OUTPUT_FILE}"
81 kill "${SERVER_PID}"
8ae912ac 82 rm -rf "${OUTPUT_DIR}"
ed870945
KS
83 sleep 5 # Let serve:prod stop
84 exit 1
85else
8ae912ac 86 rm -rf "${OUTPUT_DIR}"
ed870945
KS
87 kill "${SERVER_PID}"
88fi
89
8ae912ac 90print_header "Deploy website"
3b6ded16 91bundle exec grunt deploy:prod --network
8a02037b
JR
92
93# EOF
This page took 0.028229 seconds and 4 git commands to generate.