From 395b54c849e6f1d38d6fb01f679167b669c1c5b9 Mon Sep 17 00:00:00 2001
From: Manuel Friedli <manuel@fritteli.ch>
Date: Tue, 14 Mar 2017 23:46:57 +0100
Subject: [PATCH] Updated deploy process for the production environment.

---
 .gitlab-ci.yml | 27 ++++++++--------------
 deploy.sh      | 61 --------------------------------------------------
 2 files changed, 9 insertions(+), 79 deletions(-)
 delete mode 100755 deploy.sh

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 09fe991..f38752a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,14 +2,7 @@ stages:
   - build
   - cleanup_build
   - deploy
-#  - cleanup
-
-.run_deploy: &run_deploy
-  script:
-    - chmod +x ./deploy.sh
-    - ./deploy.sh
-#  dependencies:
-#    - build_job
+  - cleanup
 
 build_job:
   stage: build
@@ -48,17 +41,15 @@ pages:
 
 production:
   stage: deploy
-  <<: *run_deploy
   environment: production
   only:
     - master
-  variables:
-    ENVIRON: production
-    TARGET: $WWW_DEPLOY_ROOT_PRODUCTION
+  script:
+    - if [[ ! -d "${WWW_DEPLOY_ROOT_PRODUCTION}" ]] ; then mkdir -p "${WWW_DEPLOY_ROOT_PRODUCTION}" || die "Failed to create target directory for deployment!"; fi
+    - cp dist/* "${WWW_DEPLOY_ROOT_PRODUCTION}"
 
-#cleanup_job:
-#  stage: cleanup
-#  script:
-#    - rm -rf node_modules
-#    - rm -rf typings
-#  when: always
+cleanup_job:
+  stage: cleanup
+  script:
+    - rm -rf node_modules
+  when: always
diff --git a/deploy.sh b/deploy.sh
deleted file mode 100755
index c21a4f3..0000000
--- a/deploy.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/sh
-
-function die() {
-    echo $*
-    exit 1
-}
-
-declare destination
-case "${TARGET}" in
-	"${WWW_DEPLOY_ROOT_DEVELOP}")
-		destination="${TARGET}/${CI_BUILD_REF_NAME}"
-		;;
-	"${WWW_DEPLOY_ROOT_STAGING}"|"${WWW_DEPLOY_ROOT_PRODUCTION}")
-		destination="${TARGET}"
-		;;
-	*)
-		die "Invalid TARGET specified. Aborting deployment."
-		;;
-esac
-
-if [[ ! -d "${destination}" ]] ; then
-    mkdir -p "${destination}" || die "Failed to create target directory for deployment!"
-fi
-
-rm -rf "${destination}"/* || die "Failed to clean destination directory (step 1)"
-rm -rf "${destination}"/.??* || die "Failed to clean destination directory (step 2)"
-
-cp -a index.html abeezee-regular.woff freemono.* package.json systemjs.config.js "${destination}" || die "Failed to copy resources to dest/"
-
-mkdir -p "${destination}/app/converter" || die "Failed to create dest/app/converter directory"
-cp -a app/*.css app/*.html app/*.js app/*.js.map "${destination}/app" || die "Failed to copy resources to dest/app"
-cp -a app/converter/*.js app/converter/*.js.map "${destination}/app/converter" || die "Failed to copy resources to dest/app/converter"
-
-mkdir -p "${destination}/node_modules/@angular" || die "Failed to create dest/node_modules/@angular"
-cp -a node_modules/@angular/* "${destination}/node_modules/@angular/" || die "Failed to copy @angular"
-
-mkdir -p "${destination}/node_modules/core-js/client" || die "Failed to create dest/node_modules/core-js"
-cp -a node_modules/core-js/client/shim.js "${destination}/node_modules/core-js/client/" || die "Failed to copy core-js"
-
-mkdir -p "${destination}/node_modules/zone.js/dist" || die "Failed to create dest/node_modules/zone.js"
-cp -a node_modules/zone.js/dist/zone.js "${destination}/node_modules/zone.js/dist/" || die "Failed to copy zone.js"
-
-mkdir -p "${destination}/node_modules/reflect-metadata" || die "Failed to create dest/node_modules/reflect-metadata"
-cp -a node_modules/reflect-metadata/Reflect.js "${destination}/node_modules/reflect-metadata/" || die "Failed to copy Reflect.js"
-
-mkdir -p "${destination}/node_modules/rxjs" || die "Failed to create dest/node_modules/rxjs"
-cp -a node_modules/rxjs/* "${destination}/node_modules/rxjs/" || die "Failed to copy rxjs"
-
-mkdir -p "${destination}/node_modules/systemjs/dist" || die "Failed to create dest/node_modules/systemjs"
-cp -a node_modules/systemjs/dist/system.src.js "${destination}/node_modules/systemjs/dist/" || die "Failed to copy system.src.js"
-
-mkdir -p "${destination}/node_modules/utf8" || die "Failed to create dest/node_modules/utf8"
-cp -a node_modules/utf8/utf8.js "${destination}/node_modules/utf8/" || die "Failed to copy utf8.js"
-
-mkdir -p "${destination}/node_modules/quoted-printable" || die "Failed to create dest/node_modules/quoted-printable"
-cp -a node_modules/quoted-printable/quoted-printable.js "${destination}/node_modules/quoted-printable/" || die "Failed to copy quoted-printable.js"
-
-mkdir -p "${destination}/node_modules/punycode" || die "Failed to create dest/node_modules/punycode"
-cp -a node_modules/punycode/punycode.js "${destination}/node_modules/punycode/" || die "Failed to copy punycode.js"
-
-echo "Deployment successful."