From 625b9852a3e4a1efb745a3e2277ca543e5e98239 Mon Sep 17 00:00:00 2001
From: Guilherme Becker Agge <gba17@inf.ufpr.br>
Date: Thu, 5 Jul 2018 11:57:35 -0300
Subject: [PATCH] SCRUM#580: Refactor the deploy code

---
 .deploy.sh               | 23 ++++++++++++-----------
 package/debian/changelog |  6 ++++++
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/.deploy.sh b/.deploy.sh
index 934540c..473e312 100755
--- a/.deploy.sh
+++ b/.deploy.sh
@@ -6,27 +6,28 @@
 
 apt-get update && apt-get install -y dput ssh
 
-eval "$(ssh-agent -s)"
+eval $(ssh-agent -s)
 ssh-add <(echo "$PRIV_KEY")
 
 echo "Deploy job name: $CI_JOB_NAME"
 
 if [ "$CI_JOB_NAME" = "deploy_for_unstable" ]; then
     dput -u -f --config=dput.cf repo build/*.changes
-elif [ "$CI_JOB_NAME" = "deploy_for_testing" ]; then
-    CHANGELOG="package/debian/changelog"
-    LINE=$(head -n 1 $CHANGELOG)
-    PACKAGE=$(echo "$LINE" | cut -d' ' -f1)
-    VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*')
 
-    REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc testing unstable $PACKAGE $VERSION"
-    ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa repository@repo.c3sl.ufpr.br "$REPREPRO_CMD"
-elif [ "$CI_JOB_NAME" = "deploy_for_stable" ]; then
+else
+    if [ "$CI_JOB_NAME" = "deploy_for_testing" ]; then
+       REPO_SRC="unstable"
+       REPO_TGT="testing"
+    elif [ "$CI_JOB_NAME" = "deploy_for_stable" ]; then
+       REPO_SRC="testing"
+       REPO_TGT="stable"
+    if
+
     CHANGELOG="package/debian/changelog"
     LINE=$(head -n 1 $CHANGELOG)
     PACKAGE=$(echo "$LINE" | cut -d' ' -f1)
     VERSION=$(echo "$LINE" | cut -d' ' -f2 | grep -o -E '[0-9]*\.[0-9]*\.[0-9]*')
+    REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc $REPO_SRC $REPO_TGT $PACKAGE $VERSION"
 
-    REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc stable testing $PACKAGE $VERSION"
-    ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa repository@repo.c3sl.ufpr.br "$REPREPRO_CMD"
+    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null repository@repo.c3sl.ufpr.br "$REPREPRO_CMD"
 fi
diff --git a/package/debian/changelog b/package/debian/changelog
index 1b580cf..fca1543 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,3 +1,9 @@
+le-edubar (0.1.8) unstable; urgency=medium
+
+  * Refactor the CI deploy code (Closes: #580)
+
+ -- Guilherme Becker Agge <lesuporte@c3sl.ufpr.br>  Thu, 05 Jul 2018 11:55:53 -0300
+
 le-edubar (0.1.8) testing; urgency=medium
 
   * Fix query string
-- 
GitLab