From 12ff52985c3a57eea96cc0f632628818acdced5e Mon Sep 17 00:00:00 2001
From: Kwangjin Lee <k.lee-5@student.tudelft.nl>
Date: Fri, 23 Aug 2024 15:50:23 +0200
Subject: [PATCH] Update 2 files

- /build-page.sh
- /.gitlab-ci.yml
---
 .gitlab-ci.yml |  7 +++----
 build-page.sh  | 12 ++++++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 23b98de..536354a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,13 +20,12 @@ build-page:
     - chmod +x ./build-page.sh
   script:
     - |
-      if [ "$CI_COMMIT_BRANCH" == "publish" ] || [ "$CI_COMMIT_BRANCH" == "main" ]; then
-        echo "Running on branch $CI_COMMIT_BRANCH"
+      if [ "$CI_COMMIT_BRANCH" == "publish" ]; then
         ./build-page.sh "/" true
       else
-        echo "Running on other branches"
-        ./build-page.sh /draft false
+        ./build-page.sh "/draft" false
       fi
+
   artifacts:
     paths:
       - public
diff --git a/build-page.sh b/build-page.sh
index 6a7ce3f..55229b7 100644
--- a/build-page.sh
+++ b/build-page.sh
@@ -7,7 +7,7 @@ PAGE_ROOT=$(echo "$PAGE_ROOT" | sed 's:/*$::')
 
 if [ "$IS_PUBLISH_DEPLOYMENT" = true ]; then
     echo "Using publish deployment strategy"
-    # Remove the baner which identifies the book as a draft
+    # Remove the banner which identifies the site as a draft
     if ! command -v yq &>/dev/null; then
         echo "yq could not be found, the draft banner cannot be removed"
         echo "Please install yq (with APT or via https://github.com/mikefarah/yq#install) and try again"
@@ -17,7 +17,15 @@ if [ "$IS_PUBLISH_DEPLOYMENT" = true ]; then
     fi
 else
     echo "Using draft deployment strategy"
+    # Ensure the draft flag is true for non-publish deployments
+    if ! command -v yq &>/dev/null; then
+        echo "yq could not be found, the draft banner cannot be enforced"
+        echo "Please install yq (with APT or via https://github.com/mikefarah/yq#install) and try again"
+    else
+        cp _config.yml _config.yml.bak
+        yq -i '.is_draft = true' _config.yml
+    fi
 fi
 
-echo "Publishing to  page root: \"$PAGE_ROOT\""
+echo "Publishing to page root: \"$PAGE_ROOT\""
 bundle exec jekyll build -d public -b "$PAGE_ROOT"
-- 
GitLab