From 3c4e7b3f053cfc1550281e0d7865174638b1efd7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sigurd=20R=C3=B8stad=20Augdal?= <sigurdra@stud.ntnu.no>
Date: Fri, 23 Apr 2021 19:37:33 +0000
Subject: [PATCH] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index db98365..9e4bf51 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,6 +18,18 @@ build-job:
     - apt-get update -qy
     - pip3 install -r requirements.txt
     - python manage.py migrate
+      # Import credential variables
+    - ARG DJANGO_SUPERUSER_USERNAME
+    - ARG DJANGO_SUPERUSER_PASSWORD
+    - ARG DJANGO_SUPERUSER_EMAIL
+      # Create superuser
+    - RUN DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME} \
+      DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD} \
+      DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL} \
+      python manage.py createsuperuser --noinput || \
+    - echo "WARNING: This error is ignored as it most likely is 'That username is already taken.'"
+    - echo "WARNING: If you wish to alter the user credentials, then delete the user first."
+    - python manage.py loaddata seed.json
 
 test-backend:
   stage: test
-- 
GitLab