ci: Homepage should exists and non-empty

This commit is contained in:
Ming Di Leom 2021-03-14 05:13:13 +00:00
parent edcadaade0
commit c0d8e6001e
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
2 changed files with 17 additions and 0 deletions

View File

@ -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/

16
check-homepage.sh Normal file
View File

@ -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