#!/bin/sh set -e # Configuration REPO_URL="${REPO_URL:-https://git.vezpi.com/Vezpi/blog.git}" URL="${URL:-blog.vezpi.com}" BRANCH="${BRANCH:-preview}" BLOG_DIR="${BLOG_DIR:-/blog}" HUGO_CACHE_DIR="${HUGO_CACHE_DIR:-/hugo-cache}" DRAFTS="" # Add drafts for preview if [ "$BRANCH" = "preview" ]; then echo "- Adding draft pages to be generated" DRAFTS="--buildDrafts --buildFuture" fi # Clean blog dir rm -rf "$BLOG_DIR" # Create Hugo resource folder mkdir -p "$HUGO_CACHE_DIR" # Clone repo echo "- Cloning $REPO_URL (branch: $BRANCH)..." git clone --recurse-submodules --branch "$BRANCH" "$REPO_URL" "$BLOG_DIR" # Generate static files with hugo echo "- Building site with Hugo v$HUGO_VERSION in $HUGO_DEST..." hugo --source "$BLOG_DIR" \ --destination "$HUGO_DEST" \ --cacheDir "$HUGO_CACHE_DIR" \ --baseURL="https://${URL}" \ ${DRAFTS} \ --logLevel info \ --cleanDestinationDir \ --gc \ --panicOnWarning \ --printI18nWarnings # Start nginx echo "- Starting Nginx..." exec nginx -g 'daemon off;'