-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename build-site.sh to start.sh to handle build and serve
- Loading branch information
Showing
4 changed files
with
43 additions
and
8 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
nc='\033[0m' | ||
r='\033[0;31m' | ||
g='\033[0;32m' | ||
|
||
LANGS=( | ||
"en" | ||
"cn" | ||
) | ||
|
||
while [[ "$1" =~ ^"-" ]]; do | ||
if [ "$1" = "-l" ]; then | ||
shift 1; lang=$1 | ||
fi | ||
shift 1 | ||
done | ||
|
||
[ -z "$1" ] && action="serve" || action=$1 | ||
|
||
if [ -z "$lang" ]; then | ||
lang="en" | ||
elif [[ ! ${LANGS[*]} =~ $lang ]]; then | ||
echo -e "\n ERROR: Undefined lang: ${r}$lang${nc}\n" && exit 1 | ||
fi | ||
echo -e "\n ACTION: ${g}$action${nc}, LANG: ${g}$lang${nc}\n" | ||
|
||
# Provide extra options for jekyll when needed. | ||
[ "$lang" != "en" ] && jekyll_cmd_extra_options="--config _config.yml,$lang/_config.yml" | ||
|
||
# Docker compose | ||
if [ "$action" == "build" ]; then | ||
COMPOSE_FILE="compose-build-site.yaml" | ||
|
||
docker compose -f "$COMPOSE_FILE" up | ||
docker compose -f "$COMPOSE_FILE" down | ||
else | ||
JEKYLL_CMD_EXTRA_OPTIONS="$jekyll_cmd_extra_options" docker compose up | ||
fi |