Auto-deploy script for new Home Assistant config when passes in Travis CU
#!/bin/sh
if [ ! -f /tmp/last_build.txt ]; then
touch /tmp/last_build.txt
fi
current_build=`curl -H "Travis-API-Version: 3" -s https://api.travis-ci.org/repo/14706137/branch/master | jq .last_build.number`
current_build="${current_build%\"}"
current_build="${current_build#\"}"
current_status=`curl -H "Travis-API-Version: 3" -s https://api.travis-ci.org/repo/14706137/branch/master | jq .last_build.state`
current_status="${current_status%\"}"
current_status="${current_status#\"}"
last_build=`cat /tmp/last_build.txt`
if [[ "$current_status" == "passed" && "$current_build" != "$last_build" ]] ; then
cd /data/home-assistant ; git pull
rancher restart --env 1a5 automation/home-assistant
echo $current_build > /tmp/last_build.txt
fi;