mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2025-12-18 05:41:31 +00:00
Improve the CD workflow and enhance the related tools.
This commit is contained in:
@@ -16,28 +16,26 @@ CONTAINER="${WORK_DIR}/.container"
|
||||
|
||||
DEST="${WORK_DIR}/_site"
|
||||
|
||||
|
||||
_help() {
|
||||
echo "Usage:"
|
||||
echo
|
||||
echo " bash build.sh [options]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
||||
echo " -h, --help Print the help information"
|
||||
echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
|
||||
echo " -b, --baseurl <URL> The site relative url that start with slash, e.g. '/project'"
|
||||
echo " -h, --help Print the help information"
|
||||
echo " -d, --destination <DIR> Destination directory (defaults to ./_site)"
|
||||
}
|
||||
|
||||
|
||||
_init() {
|
||||
cd "$WORK_DIR"
|
||||
|
||||
if [[ -d "$CONTAINER" ]]; then
|
||||
if [[ -d $CONTAINER ]]; then
|
||||
rm -rf "$CONTAINER"
|
||||
fi
|
||||
|
||||
if [[ -d "_site" ]]; then
|
||||
jekyll clean
|
||||
if [[ -d $DEST ]]; then
|
||||
bundle exec jekyll clean
|
||||
fi
|
||||
|
||||
local _temp="$(mktemp -d)"
|
||||
@@ -46,7 +44,6 @@ _init() {
|
||||
mv "$_temp" "$CONTAINER"
|
||||
}
|
||||
|
||||
|
||||
_build() {
|
||||
cd "$CONTAINER"
|
||||
echo "$ cd $(pwd)"
|
||||
@@ -60,7 +57,7 @@ _build() {
|
||||
echo -e "\nBuild success, the site files have been placed in '${DEST}'."
|
||||
|
||||
if [[ -d "${DEST}/.git" ]]; then
|
||||
if [[ ! -z $(git -C "$DEST" status -s) ]]; 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"
|
||||
@@ -70,37 +67,33 @@ _build() {
|
||||
cd .. && rm -rf "$CONTAINER"
|
||||
}
|
||||
|
||||
|
||||
_check_unset() {
|
||||
if [[ -z ${1:+unset} ]]
|
||||
then
|
||||
if [[ -z ${1:+unset} ]]; then
|
||||
_help
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
while [[ $# -gt 0 ]]; do
|
||||
opt="$1"
|
||||
case $opt in
|
||||
-b|--baseurl)
|
||||
-b | --baseurl)
|
||||
local _baseurl="$2"
|
||||
if [[ -z "$_baseurl" ]]; then
|
||||
if [[ -z $_baseurl ]]; then
|
||||
_baseurl='""'
|
||||
fi
|
||||
CMD+=" -b $_baseurl"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-d|--destination)
|
||||
-d | --destination)
|
||||
_check_unset "$2"
|
||||
DEST="$(realpath "$2")"
|
||||
shift;
|
||||
shift;
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
-h | --help)
|
||||
_help
|
||||
exit 0
|
||||
;;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
# Requirement: https://github.com/gjtorikian/html-proofer
|
||||
#
|
||||
# Usage: bash /path/to/test.sh
|
||||
# Usage: bash /path/to/test.sh [indicated path]
|
||||
#
|
||||
# v2.0
|
||||
# https://github.com/cotes2020/jekyll-theme-chirpy
|
||||
@@ -14,6 +14,10 @@
|
||||
DEST=_site
|
||||
URL_IGNORE=cdn.jsdelivr.net
|
||||
|
||||
if [[ -n $1 && -d $1 ]]; then
|
||||
DEST=$1
|
||||
fi
|
||||
|
||||
bundle exec htmlproofer $DEST \
|
||||
--disable-external \
|
||||
--check-html \
|
||||
|
||||
Reference in New Issue
Block a user