diff --git a/.ci-scripts/build.sh b/.ci-scripts/build.sh
new file mode 100644
index 0000000000000000000000000000000000000000..4717b0789787246562eef1980871c4adfc6c0bea
--- /dev/null
+++ b/.ci-scripts/build.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# This script has originally been a template at .gitlab-ci.yml.
+# In order to use it within a Bash conditional we moved it to this script file.
+
+bash .ci-scripts/set_entrypoint_ci.sh
+npm install
+npm run build
+npm run tweak:build
\ No newline at end of file
diff --git a/.ci-scripts/remove_entrypoint.sh b/.ci-scripts/remove_entrypoint.sh
new file mode 100644
index 0000000000000000000000000000000000000000..8a6e8cf93dee7a57c493cd350eebdbd6306e1d17
--- /dev/null
+++ b/.ci-scripts/remove_entrypoint.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+FILE="src/index.template.html"
+
+if grep -q '"entrypoint": ""' "$FILE"; then 
+    echo "No entry point update required."
+    echo "CONTINUE_BUILD=true" >> build.env
+else
+    echo "Entry point has to be removed."
+    mkdir -p /tmp/this && cd /tmp/this || exit
+    git clone git@gitlab.gwdg.de:subugoe/emo/QViewer.git
+    cd QViewer || exit
+    sed -i 's/"entrypoint": ".*"/"entrypoint": ""/' src/index.template.html
+    git add src/index.template.html && git commit -m "ci: remove entry point" && git push
+    echo "CONTINUE_BUILD=false" >> build.env
+fi
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9bb3b626a5f36f5fb1cdb3555010625d4c020921..4ad53e9fb7f85b3a6397ef9d3ca90422c6d42773 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,16 +3,33 @@ cache:
   - node_modules/
 
 stages:
+  - clean
   - build
   - deploy
   - preserve-pages
 
 # Templates
-.build: &build
-   - bash .ci-scripts/set_entrypoint_ci.sh
-   - npm install
-   - npm run build
-   - npm run tweak:build
+.git: &git
+  - eval $(ssh-agent -s)
+  - echo "$DEPLOY_KEY" | tr -d '\r' | ssh-add - > /dev/null
+  - mkdir -p ~/.ssh
+  - chmod 700 ~/.ssh
+  - ssh-keyscan gitlab.gwdg.de  >> ~/.ssh/known_hosts
+  - git config --global user.email "tido@gitlab.gwdg.de"
+  - git config --global user.name "Gitlab CI"
+
+clean_up:
+  image: docker.gitlab.gwdg.de/mrodzis/docker-images/debian
+  stage: clean
+  only:
+    - main
+    - develop
+  script:
+    - *git
+    - bash .ci-scripts/remove_entrypoint.sh
+  artifacts:
+    reports:
+      dotenv: build.env
 
 build_test:
   image: docker.gitlab.gwdg.de/subugoe/emo/qviewer/node:latest
@@ -21,7 +38,7 @@ build_test:
    - develop
   stage: build
   script:
-   - *build
+   - bash .ci-scripts/build.sh
   artifacts:
     paths:
      - dist/
@@ -33,7 +50,7 @@ build_main_and_develop:
    - develop
   stage: build
   script:
-   - *build
+   - if [[ $CONTINUE_BUILD == "true" ]]; then bash .ci-scripts/build.sh; fi
   artifacts:
     paths:
      - dist/
@@ -83,21 +100,6 @@ pushback:
     paths:
       - updated-artifact.zip
 
-.production:
-  image: node:latest
-  only:
-    - main
-  stage: deploy
-  script:
-   - npm install
-   - npm run build
-   - npm run tweak:build
-   - mkdir tido && mv dist/* tido/
-  artifacts:
-    expire_in: 5 yrs
-    paths:
-     - tido
-
 # when a git flow release is made, a tag will be pushed starting this job. it
 # will keep the resulting artifact from the job declared in `JOB_NUMBER_TO_PRESERVE`
 # and it will set up a Gitlab release at the repo. therefore the merge message starting