From 870f8bd9800aed2f9b9f7cae90ca23bd59a25185 Mon Sep 17 00:00:00 2001
From: Kwangjin Lee <k.lee-5@student.tudelft.nl>
Date: Fri, 23 Aug 2024 12:32:45 +0200
Subject: [PATCH] Update .gitlab-ci.yml file

---
 .gitlab-ci.yml | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b3e5c78..521bf6f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,12 +18,32 @@ before_script:
 build-page:
   stage: build
   script:
-    - mkdir -p public
-    - cp -r * public/ || true
-    - echo $CI_COMMIT_SHA > public/version.txt
+    - |
+      if [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
+        echo "Building draft site..."
+        JEKYLL_ENV=production bundle exec jekyll build --config _config_draft.yml --destination public
+      elif [[ "$CI_COMMIT_BRANCH" == "publish" ]]; then
+        echo "Building production site..."
+        JEKYLL_ENV=production bundle exec jekyll build --config _config.yml --destination public
+      else
+        echo "Branch is neither main nor publish. Skipping build."
+        exit 1
+      fi
+    - cp _config.yml public/
+    - cp _config_draft.yml public/
+    - cp home.md public/
+    - cp -R _includes public/
+    - cp -R _layouts public/
+    - cp -R _sass public/
+    - cp -R assets public/
+    - cp Gemfile public/
+    - cp Gemfile.lock public/
+    - echo "Listing contents of public directory:"
+    - ls -laR public
   artifacts:
     paths:
       - public
+    expire_in: 1 week
   rules:
     - if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "publish"
 
-- 
GitLab