This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·50 lines (41 loc) · 1.78 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
main() {
# These are declared in the netlify.toml file.
# declare DART_SASS_VERSION=1.63.5
# declare STORK_VERSION=1.5.0
declare STORK_CONFIG_FILE=stork.config.json # generated by hugo
declare STORK_INDEX_FILE=stork.index.json # generated by stork (json suffix triggers gzip/br compression)
declare STORK_EXEC=stork-ubuntu-20-04
declare STORK_URL="https://github.com/jameslittle230/stork/releases/download/v${STORK_VERSION}/${STORK_EXEC}"
declare HUGO_PUBLISH_DIR=public
# Install Stork if it's not already installed.
if [[ ! -f "${STORK_EXEC}" ]]; then
echo -e "\nInstalling Stork...\n"
wget --no-verbose "${STORK_URL}" ||
{ echo "Error: unable to wget ${STORK_URL}"; exit 1; }
chmod +x "${STORK_EXEC}" ||
{ echo "Error: unable to chmod ${STORK_EXEC}"; exit 1; }
fi
# Install Dart Sass.
echo "Installing Dart Sass..."
curl -LJO https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
tar -xf dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
rm dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz
export PATH=/opt/build/repo/dart-sass:$PATH
# Configure Git
# See https://github.com/gohugoio/hugo/issues/9810
if [[ "${CI:-false}" == "true" ]]; then
git config --global core.quotepath false ||
{ echo "Error: unable to configure Git"; exit 1; }
fi
# Build the site.
echo -e "\nBuilding site...\n"
hugo --gc --minify ||
{ echo "Error: unable to run hugo"; exit 1; }
# Build the Stork index.
echo -e "\nBuilding Stork index...\n"
./${STORK_EXEC} build --input "${HUGO_PUBLISH_DIR}/${STORK_CONFIG_FILE}" --output "${HUGO_PUBLISH_DIR}/${STORK_INDEX_FILE}" ||
{ echo "Error: unable to run stork"; exit 1; }
}
set -euo pipefail
main "$@"