From c0d8e6001e1decf01377640271a9537de6527f86 Mon Sep 17 00:00:00 2001 From: Ming Di Leom <2809763-curben@users.noreply.gitlab.com> Date: Sun, 14 Mar 2021 05:13:13 +0000 Subject: [PATCH] ci: Homepage should exists and non-empty --- .gitlab-ci.yml | 1 + check-homepage.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 check-homepage.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27eae18..f0e673b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,7 @@ test: script: - npm install snyk && npm run snyk # Refer to "scripts" in package.json - npm run build # Generate site + - sh check-homepage.sh # Homepage should exists and non-empty after_script: - rsync -azvh --delete public/ host-1:/var/www/ diff --git a/check-homepage.sh b/check-homepage.sh new file mode 100644 index 0000000..37e9e36 --- /dev/null +++ b/check-homepage.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +## Homepage should exists and non-empty + +HOMEPAGE="public/index.html" + +if [ ! -f "$HOMEPAGE" ]; then + echo "Error: homepage doesn't exist" + exit 1 +else + FILE_SIZE=$(ls -s "$HOMEPAGE" | cut -d" " -f1) + if [ "$FILE_SIZE" = 0 ]; then + echo "Error: homepage is empty" + exit 1 + fi +fi