blokmap/deploy.sh

28 lines
722 B
Bash
Raw Normal View History

2017-07-29 12:45:46 +00:00
#!/bin/bash
set -euo pipefail
declare dir=$(pwd)
2017-07-29 12:45:46 +00:00
declare timestamp=$(date +%Y-%m-%d_%H%M)
declare release_dir="$dir/releases/$timestamp"
2017-07-29 12:45:46 +00:00
# Pull latest revision
echo "-> Pulling latest release"
# Apparently, some systems put "up to date", while others put "up-to-date"
2018-08-12 09:45:50 +00:00
git pull | grep 'Already up[- ]to[- ]date.' && echo "No updates, exiting..." && exit 20
2017-07-29 12:45:46 +00:00
2017-07-29 13:08:27 +00:00
2017-07-29 12:45:46 +00:00
# Create release dir and copy sources to that dir
echo "-> This release will be stored in $release_dir"
2017-07-29 12:45:46 +00:00
mkdir -p "$release_dir"
cp -ar src/* "$release_dir"
# Link this relase to $current
echo "-> Linking $dir/current to $release_dir"
rm "$dir/current" || true # This may fail
ln -sf "$dir/releases/$timestamp" "$dir/current"
echo "-> Deployed succesfully!"