Don't deploy when no changes happened
This commit is contained in:
parent
1401292b23
commit
ff43a2d43b
30
.ci/deploy
30
.ci/deploy
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
set -Eeu
|
||||
|
||||
DEPLOY_HOST=172.19.11.5
|
||||
|
||||
@ -11,6 +11,8 @@ cat >>~/.ssh/known_hosts <<END
|
||||
END
|
||||
chmod 0600 ~/.ssh/known_hosts
|
||||
|
||||
ROOT_COMMIT=$(git rev-list HEAD | tail -n 1)
|
||||
|
||||
echo "$DEPLOY_KEY" >deploy-key
|
||||
chmod 0600 ./deploy-key
|
||||
BUILDSTAMP=$(cat binaries/buildstamp)
|
||||
@ -18,6 +20,26 @@ tar -cvJf binary-archive-$BUILDSTAMP.tar.xz -C binaries blastmud_game blastmud_l
|
||||
scp -i deploy-key binary-archive-$BUILDSTAMP.tar.xz blast@$DEPLOY_HOST:/home/blast/archive/
|
||||
ssh -i deploy-key blast@$DEPLOY_HOST "find /home/blast/archive -mtime +30 -delete && mkdir -p /home/blast/latest && tar -xvJf /home/blast/archive/binary-archive-$BUILDSTAMP.tar.xz -C /home/blast/latest"
|
||||
|
||||
# In the future, we should wrap this in a check it is needed...
|
||||
ssh -i deploy-key blast@$DEPLOY_HOST "cp /home/blast/latest/blastmud_game /mnt/gameserver-app/tmp && mv /mnt/gameserver-app/tmp/blastmud_game /mnt/gameserver-app/exe"
|
||||
ssh -i deploy-key blast@$DEPLOY_HOST "cp /home/blast/latest/blastmud_listener /mnt/listener-app/tmp && mv /mnt/listener-app/tmp/blastmud_listener /mnt/listener-app/exe"
|
||||
curl --max-time 10 https://blastmud.org/version || true >version
|
||||
LISTENER_VERSION=$(jq -r .listener_version version || echo ROOT_COMMIT)
|
||||
GAMESERVER_VERSION=$(jq -r .gameserver_version version || echo ROOT_COMMIT)
|
||||
CURRENT_VERSION=$(git rev-parse HEAD)
|
||||
|
||||
LISTENER_CHANGES=$(git diff $LISTENER_VERSION $CURRENT_VERSION -- blastmud_listener blastmud_interfaces | wc -l)
|
||||
GAMESERVER_CHANGES=$(git diff $LISTENER_VERSION $CURRENT_VERSION -- blastmud_gameserver blastmud_interfaces | wc -l)
|
||||
|
||||
echo Listener changes: $LISTENER_CHANGES Gameserver changes: $GAMESERVER_CHANGES
|
||||
|
||||
if [[ $GAMESERVER_CHANGES != "0" ]]; then
|
||||
echo Deploying gameserver
|
||||
ssh -i deploy-key blast@$DEPLOY_HOST "cp /home/blast/latest/blastmud_game /mnt/gameserver-app/tmp && mv /mnt/gameserver-app/tmp/blastmud_game /mnt/gameserver-app/exe"
|
||||
else
|
||||
echo No changes to gameserver, skipping.
|
||||
fi
|
||||
|
||||
if [[ $LISTENER_CHANGES != "0" ]]; then
|
||||
echo Deploying listener
|
||||
ssh -i deploy-key blast@$DEPLOY_HOST "cp /home/blast/latest/blastmud_listener /mnt/listener-app/tmp && mv /mnt/listener-app/tmp/blastmud_listener /mnt/listener-app/exe"
|
||||
else
|
||||
echo No changes to listener, skipping.
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user