From b20f46cdb675080bb5fa018df92537214f16a875 Mon Sep 17 00:00:00 2001
From: Brieuc Dubois <brieuc.a.dubois@student.uclouvain.be>
Date: Sun, 17 Nov 2024 13:07:39 +0000
Subject: [PATCH] Continuous Deployement

---
 .gitignore        |  1 +
 .gitlab-ci.yml    | 14 ++++++++++++++
 scripts/update.sh |  7 +++++++
 3 files changed, 22 insertions(+)
 create mode 100755 scripts/update.sh

diff --git a/.gitignore b/.gitignore
index 3f1d2a8e..2d76a9a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
 *.pem
 
 .ipynb_checkpoints/
+scripts/surveys/.creds
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0f8e3602..7b759509 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,9 +1,12 @@
 stages:
   - lint
   - build
+  - deploy
 
 lint_frontend:
   stage: lint
+  except:
+    - feat/cd
   image: node
   script:
     - cd frontend
@@ -12,6 +15,8 @@ lint_frontend:
 
 lint_backend:
   stage: lint
+  except:
+    - feat/cd
   image: registry.gitlab.com/pipeline-components/black:latest
   script:
     - black --check --verbose -- .
@@ -31,3 +36,12 @@ build:
   script:
     - docker build -t $CI_REGISTRY/sbibauw/languagelab:$COMPONENT $COMPONENT
     - docker push $CI_REGISTRY/sbibauw/languagelab:$COMPONENT
+
+docker_deploy:
+  stage: deploy
+  only:
+    - main
+    - feat/cd
+  image: alpine:latest
+  script:
+    - echo "/mnt/data/languagelab/repo/scripts/update.sh" > /mnt/pipeline
diff --git a/scripts/update.sh b/scripts/update.sh
new file mode 100755
index 00000000..030cb9aa
--- /dev/null
+++ b/scripts/update.sh
@@ -0,0 +1,7 @@
+echo "STARTED UPDATE AT $(date)" > /tmp/docker_update
+cd /mnt/data/languagelab/repo/
+git pull
+docker compose up -d
+cd scripts/surveys
+python3 survey_maker.py < .creds
+echo "END UPDATE AT $(date)" >> /tmp/docker_update
-- 
GitLab