From 65bdabd78cf2d2524c2e2f6ee00bb2355201bccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Wed, 27 Oct 2021 01:20:26 +0200 Subject: [PATCH] More deploy messages, fix mkdir -p issue --- .drone.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index ddebdbd..40c4cd9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,7 +3,7 @@ type: docker name: testing steps: -- name: test +- name: unittests image: golang:1.17-buster environment: SNAPSHOTS_S3_ENDPOINT: minio:9000 @@ -42,16 +42,24 @@ steps: image: debian:buster environment: #NODE: node-x.rosti.cz - NODE: 192.168.1.236 + NODES: 192.168.1.236 SSH_KEY: from_secret: SSH_KEY commands: - apt update && apt install -y ssh - - mkdir ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 - - ssh-keyscan $NODE > ~/.ssh/known_hosts - - scp node-api root@$NODE:/usr/local/bin/node-api_ - - ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api - - ssh root@$NODE systemctl restart node-api + - | + for NODE in $NODES; do + echo "\033[0;32mDeploying $NODE\033[0m" + mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 + echo "\033[1;33m.. scanning SSH keys\033[0m" + ssh-keyscan $NODE > ~/.ssh/known_hosts + echo "\033[1;33m.. copying the binary\033[0m" + scp node-api root@$NODE:/usr/local/bin/node-api_ + echo "\033[1;33m.. replacing the binary\033[0m" + ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api + echo "\033[1;33m.. restarting service file\033[0m" + ssh root@$NODE systemctl restart node-api + done trigger: branch: @@ -89,10 +97,14 @@ steps: - | for NODE in $NODES; do echo "\033[0;32mDeploying $NODE\033[0m" - mkdir ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 + mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519 + echo "\033[1;33m.. scanning SSH keys\033[0m" ssh-keyscan $NODE > ~/.ssh/known_hosts + echo "\033[1;33m.. copying the binary\033[0m" scp node-api root@$NODE:/usr/local/bin/node-api_ + echo "\033[1;33m.. replacing the binary\033[0m" ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api + echo "\033[1;33m.. restarting service file\033[0m" ssh root@$NODE systemctl restart node-api done