From 59235b07378f07e8dbe76a55defd4bbd05cde93d Mon Sep 17 00:00:00 2001
From: Kwangjin Lee <k.lee-5@student.tudelft.nl>
Date: Fri, 23 Aug 2024 16:06:12 +0200
Subject: [PATCH] revert

---
 .gitlab-ci.yml | 19 +++++++++----------
 build-page.sh  | 21 ++++++++++++++++-----
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 335df3b..23b98de 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,6 +10,8 @@ variables:
 
 build-page:
   stage: build
+  variables:
+    JEKYLL_ENV: production
   before_script:
     - gem install bundler
     - bundle install
@@ -18,15 +20,12 @@ build-page:
     - chmod +x ./build-page.sh
   script:
     - |
-      if [ "$CI_COMMIT_BRANCH" == "publish" ]; then
-        echo "Running production build for publish branch"
-        ./build-page.sh "/" "_config.yml"
-      elif [ "$CI_COMMIT_BRANCH" == "main" ]; then
-        echo "Running draft build for main branch"
-        ./build-page.sh "/draft" "_config_draft.yml"
+      if [ "$CI_COMMIT_BRANCH" == "publish" ] || [ "$CI_COMMIT_BRANCH" == "main" ]; then
+        echo "Running on branch $CI_COMMIT_BRANCH"
+        ./build-page.sh "/" true
       else
-        echo "Branch $CI_COMMIT_BRANCH is not configured for building."
-        exit 1
+        echo "Running on other branches"
+        ./build-page.sh /draft false
       fi
   artifacts:
     paths:
@@ -43,7 +42,7 @@ deploy-draft:
     - |
       curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy-draft \
         -H "Content-Type: application/json" \
-        -H "X-Gitlab-Token: YOUR_TOKEN_HERE" \
+        -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
         -d '{
           "object_kind": "pipeline",
           "object_attributes": {
@@ -65,7 +64,7 @@ deploy-production:
     - |
       curl -X POST https://mude.citg.tudelft.nl/hooks/website-deploy \
         -H "Content-Type: application/json" \
-        -H "X-Gitlab-Token: YOUR_TOKEN_HERE" \
+        -H "X-Gitlab-Token: glpat-sQ82fiSMo1kCi2TpgSfr" \
         -d '{
           "object_kind": "pipeline",
           "object_attributes": {
diff --git a/build-page.sh b/build-page.sh
index 8219c62..6a7ce3f 100644
--- a/build-page.sh
+++ b/build-page.sh
@@ -1,12 +1,23 @@
 #!/bin/bash
 
 PAGE_ROOT=${1:-"/"}
-CONFIG_FILE=${2:-"_config.yml"}
+IS_PUBLISH_DEPLOYMENT=${2:-false}
 
 PAGE_ROOT=$(echo "$PAGE_ROOT" | sed 's:/*$::')
 
-echo "Using configuration file: $CONFIG_FILE"
-echo "Publishing to page root: \"$PAGE_ROOT\""
+if [ "$IS_PUBLISH_DEPLOYMENT" = true ]; then
+    echo "Using publish deployment strategy"
+    # Remove the baner which identifies the book 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"
+    else
+        cp _config.yml _config.yml.bak
+        yq -i '.is_draft = false' _config.yml
+    fi
+else
+    echo "Using draft deployment strategy"
+fi
 
-# Execute the Jekyll build command with the selected config file
-bundle exec jekyll build -d public -b "$PAGE_ROOT" --config "$CONFIG_FILE"
+echo "Publishing to  page root: \"$PAGE_ROOT\""
+bundle exec jekyll build -d public -b "$PAGE_ROOT"
-- 
GitLab