From 2376f1e5a717aa891d213599a3dfdff2ad05b126 Mon Sep 17 00:00:00 2001
From: Guilherme Becker Agge <gba17@inf.ufpr.br>
Date: Fri, 6 Jul 2018 11:53:46 -0300
Subject: [PATCH] SCRUM#580: Refactor the deploy code

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

diff --git a/.deploy.sh b/.deploy.sh
index 14a8c58..ca609fb 100755
--- a/.deploy.sh
+++ b/.deploy.sh
@@ -12,22 +12,21 @@ 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"
-    # shellcheck disable=SC2029
-    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"
+    fi
+
     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_TGT $REPO_SRC $PACKAGE $VERSION"
 
-    REPREPRO_CMD="reprepro -Vb /home/repository/www/le6 copysrc stable testing $PACKAGE $VERSION"
-    # shellcheck disable=SC2029
-    ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -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 e1b4068..b9c04d6 100644
--- a/package/debian/changelog
+++ b/package/debian/changelog
@@ -1,3 +1,9 @@
+le-laptop-controlpanel (0.2.1) unstable; urgency=medium
+
+  * Refactor the CI deploy code (Closes: #580)
+
+ -- Guilherme Becker Agge <lesuporte@c3sl.ufpr.br>  Fri, 06 Jul 2018 11:52:16 -0300
+
 le-laptop-controlpanel (0.2.1) unstable; urgency=medium
 
   * Fix switchStandby
-- 
GitLab