From 08354cc4f525437c9e19b9f946e29d64f298707b Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 20 Nov 2020 15:59:35 +0800 Subject: [PATCH] Fix the test tool and CD hook --- .github/workflows/pages-deploy.yml.hook | 8 ++++++-- tools/test.sh | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pages-deploy.yml.hook b/.github/workflows/pages-deploy.yml.hook index 322f5e0..dbbe3a0 100644 --- a/.github/workflows/pages-deploy.yml.hook +++ b/.github/workflows/pages-deploy.yml.hook @@ -67,8 +67,12 @@ jobs: - name: Test Site run: | - bash tools/test.sh "$SPEC_TEST" - + if [[ -n $SPEC_TEST ]]; then + bash tools/test.sh -d "$SPEC_TEST" + else + bash tools/test.sh + fi + - name: Deploy run: | bash tools/deploy.sh diff --git a/tools/test.sh b/tools/test.sh index 0eda427..6ff57f0 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -22,8 +22,9 @@ help() { echo " bash ./tools/test.sh [options]" echo echo "Options:" - echo " --build Run jekyll build before testing." - echo " -h, --help Print this information." + echo " --build Run Jekyll build before test." + echo " -d, --dir Specify the test path." + echo " -h, --help Print this information." } if [[ -n $1 && -d $1 ]]; then @@ -37,6 +38,16 @@ while (($#)); do _build=true shift ;; + -d | --dir) + if [[ ! -d $2 ]]; then + echo -e "Error: path '$2' doesn't exist\n" + help + exit 1 + fi + DEST=$2 + shift + shift + ;; -h | --help) help exit 0