diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0f4a75abe400abcad979b035b368e17fb40a7f76..4e6377942851c431458a9a802f88fb7f3bf5f6a0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,34 +1,37 @@
 image: digitallyseamless/nodejs-bower-grunt
 
 pages:
-  stage: build
-  only:
-    - develop
-  script:
-    - npm install -g npm@latest yo grunt-cli generator-reveal bower
-    - npm install
-    - grunt dist
-    - mkdir latest
-    - mv public/* latest/.
-    - mv latest public/.
-    - cp .autoRedirect public/index.html
-
-  artifacts:
-    paths:
-      - public/latest
-
   stage: deploy
   only:
+    - develop
     - master
   script:
+    # install npm
     - npm install -g npm@latest yo grunt-cli generator-reveal bower
     - npm install
+
+    # build the master version into stable
+    - git fetch --tags
+    - latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
+    - git checkout $latestTag
     - grunt dist
     - mkdir stable
     - mv public/* stable/.
+
+    # build the develop version into latest
+    - git checkout develop
+    - git pull origin develop
+    - grunt dist
+    - mkdir latest
+    - mv public/* latest/.
+
+    # deploy the stable and latest directories
     - mv stable public/.
+    - mv latest public/.
+
+    # auto redirect file
     - cp .autoRedirect public/index.html
 
   artifacts:
     paths:
-      - public/stable
+      - public