merge ci steps
This commit is contained in:
30
scripts/deploy.sh
Normal file
30
scripts/deploy.sh
Normal file
@ -0,0 +1,30 @@
|
||||
# !/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Setup SSH Agent
|
||||
eval $(ssh-agent -s)
|
||||
printenv SSH_PRIVATE_KEY | base64 -d | ssh-add -
|
||||
|
||||
# Approve home.loyso.art
|
||||
mkdir ~/.ssh
|
||||
ssh-keyscan home.loyso.art > $HOME/.ssh/known_hosts
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
# Setup useful vars.
|
||||
SRC_DIR="/opt/${APP_NAME}"
|
||||
SRC_APP="${SRC_DIR}/${APP_NAME}"
|
||||
SSH_PREFIX="${SSH_USER}@home.loyso.art"
|
||||
|
||||
echo $SSH_PREFIX
|
||||
echo $SRC_APP
|
||||
|
||||
ssh $SSH_PREFIX -C "sudo systemctl stop ${APP_NAME}" || true
|
||||
ssh $SSH_PREFIX -C "mv ${SRC_APP} ${SRC_APP}_$(date +'%s')" || true
|
||||
# Copy binary to host machine.
|
||||
scp ${TARGET_DIR}/${APP_NAME} ${SSH_USER}@home.loyso.art:${SRC_APP}
|
||||
|
||||
# Keep only last 3 versions.
|
||||
ssh $SSH_PREFIX -C "cd ${SRC_DIR};echo \$(ls ${APP_NAME}_* | sort | head -n -2)"
|
||||
|
||||
ssh $SSH_PREFIX -C "sudo systemctl start ${APP_NAME}"
|
||||
Reference in New Issue
Block a user