Commit | Line | Data |
---|---|---|
5b461c35 KS |
1 | #!/bin/bash |
2 | # shellcheck disable=SC2103 | |
3 | # | |
4 | # Copyright (C) 2022 Kienan Stewart <kstewart@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 | ||
19 | set -exu | |
20 | ||
21 | # Add ssh key for deployment | |
22 | cp "$HOST_PUBLIC_KEYS" ~/.ssh/known_hosts | |
23 | cp "$KEY_FILE_VARIABLE" ~/.ssh/id_rsa | |
24 | ||
00c49046 KS |
25 | apt-get update |
26 | ||
5b461c35 | 27 | # Nodejs |
00c49046 | 28 | apt-get install --no-install-recommends -y npm |
5b461c35 KS |
29 | ./bootstrap-ubuntu.sh |
30 | npm install | |
31 | ||
32 | grunt build:dev --verbose | |
33 | grunt deploy:pre --verbose | |
34 | ||
35 | grunt build:prod --verbose | |
00c49046 KS |
36 | |
37 | # Check for broken internal links | |
38 | apt-get install -y linkchecker | |
39 | grunt connect:prod watch:prod & | |
40 | SERVER_PID="${!}" | |
41 | sleep 10 # While serve:prod starts up | |
42 | OUTPUT_FILE="$(mktemp -d)/linkchecker-out.csv" | |
43 | # linkchecker drops privileges to 'nobody' when run as root | |
44 | chown nobody "$(dirname "${OUTPUT_FILE}")" | |
45 | # @Note: Only internal links are checked by default | |
46 | if ! linkchecker -q -F "csv/utf-8/${OUTPUT_FILE}" http://localhost:10000/ ; then | |
47 | echo "Linkchecker failed or found broken links" | |
48 | cat "${OUTPUT_FILE}" | |
49 | kill "${SERVER_PID}" | |
50 | rm -rf "${OUTPUT_FILE}/.." | |
51 | sleep 5 # Let serve:prod stop | |
52 | exit 1 | |
53 | else | |
54 | rm -rf "${OUTPUT_FILE}/.." | |
55 | kill "${SERVER_PID}" | |
56 | fi | |
57 | ||
5b461c35 KS |
58 | grunt deploy:prod --verbose |
59 | # EOF |