Add --config
option to the build-tool.
This commit is contained in:
parent
c98fd19900
commit
a95d6d7101
1 changed files with 33 additions and 19 deletions
|
@ -8,26 +8,29 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
CMD="JEKYLL_ENV=production bundle exec jekyll b"
|
|
||||||
|
|
||||||
WORK_DIR="$(dirname "$(dirname "$(realpath "$0")")")"
|
WORK_DIR="$(dirname "$(dirname "$(realpath "$0")")")"
|
||||||
|
|
||||||
CONTAINER="${WORK_DIR}/.container"
|
CONTAINER="${WORK_DIR}/.container"
|
||||||
|
|
||||||
DEST="${WORK_DIR}/_site"
|
dest="${WORK_DIR}/_site"
|
||||||
|
|
||||||
|
cmd="JEKYLL_ENV=production bundle exec jekyll b"
|
||||||
|
|
||||||
docker=false
|
docker=false
|
||||||
|
|
||||||
|
config=""
|
||||||
|
|
||||||
_help() {
|
_help() {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo
|
echo
|
||||||
echo " bash build.sh [options]"
|
echo " bash build.sh [options]"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
||||||
echo " -h, --help Print the help information"
|
echo " -h, --help Print the help information"
|
||||||
echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
|
echo " -d, --destination <DIR> destination directory (defaults to ./_site)"
|
||||||
echo " --docker Build site within docker"
|
echo " --docker Build site within docker"
|
||||||
|
echo " --config <CONFIG_a[,CONFIG_b]> Specify config files"
|
||||||
}
|
}
|
||||||
|
|
||||||
_install_tools() {
|
_install_tools() {
|
||||||
|
@ -48,7 +51,7 @@ _init() {
|
||||||
rm -rf "$CONTAINER"
|
rm -rf "$CONTAINER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d $DEST ]]; then
|
if [[ -d $dest ]]; then
|
||||||
bundle exec jekyll clean
|
bundle exec jekyll clean
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -65,16 +68,21 @@ _build() {
|
||||||
bash "_scripts/sh/create_pages.sh"
|
bash "_scripts/sh/create_pages.sh"
|
||||||
bash "_scripts/sh/dump_lastmod.sh"
|
bash "_scripts/sh/dump_lastmod.sh"
|
||||||
|
|
||||||
CMD+=" -d $DEST"
|
cmd+=" -d $dest"
|
||||||
echo "\$ $CMD"
|
|
||||||
eval "$CMD"
|
|
||||||
echo -e "\nBuild success, the site files have been placed in '${DEST}'."
|
|
||||||
|
|
||||||
if [[ -d "${DEST}/.git" ]]; then
|
if [[ -n $config ]]; then
|
||||||
if [[ -n $(git -C "$DEST" status -s) ]]; then
|
cmd+=" --config $config"
|
||||||
git -C "$DEST" add .
|
fi
|
||||||
git -C "$DEST" commit -m "[Automation] Update site files." -q
|
|
||||||
echo -e "\nPlease push the changes of $DEST to remote master branch.\n"
|
echo "\$ $cmd"
|
||||||
|
eval "$cmd"
|
||||||
|
echo -e "\nBuild success, the site files have been placed in '${dest}'."
|
||||||
|
|
||||||
|
if [[ -d "${dest}/.git" ]]; then
|
||||||
|
if [[ -n $(git -C "$dest" status -s) ]]; then
|
||||||
|
git -C "$dest" add .
|
||||||
|
git -C "$dest" commit -m "[Automation] Update site files." -q
|
||||||
|
echo -e "\nPlease push the changes of $dest to remote master branch.\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -97,13 +105,13 @@ main() {
|
||||||
if [[ -z $_baseurl ]]; then
|
if [[ -z $_baseurl ]]; then
|
||||||
_baseurl='""'
|
_baseurl='""'
|
||||||
fi
|
fi
|
||||||
CMD+=" -b $_baseurl"
|
cmd+=" -b $_baseurl"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-d | --destination)
|
-d | --destination)
|
||||||
_check_unset "$2"
|
_check_unset "$2"
|
||||||
DEST="$(realpath "$2")"
|
dest="$(realpath "$2")"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
@ -111,6 +119,12 @@ main() {
|
||||||
docker=true
|
docker=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--config)
|
||||||
|
_check_unset "$2"
|
||||||
|
config="$(realpath "$2")"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
_help
|
_help
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue