2017-07-29 14:45:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2017-07-29 14:52:27 +02:00
|
|
|
declare dir=$(pwd)
|
|
|
|
|
2017-07-29 14:45:46 +02:00
|
|
|
declare timestamp=$(date +%Y-%m-%d_%H%M)
|
|
|
|
|
2017-07-29 14:52:27 +02:00
|
|
|
declare release_dir="$dir/releases/$timestamp"
|
|
|
|
|
2017-07-29 14:45:46 +02:00
|
|
|
|
|
|
|
# Pull latest revision
|
2017-07-29 14:52:27 +02:00
|
|
|
echo "-> Pulling latest release"
|
2018-08-12 11:29:10 +02:00
|
|
|
git pull | grep 'Already up to date.' && echo "No updates, exiting..." && exit 0
|
2017-07-29 14:45:46 +02:00
|
|
|
|
2017-07-29 15:08:27 +02:00
|
|
|
echo "-> Checking validity of data.json"
|
2017-07-29 15:16:26 +02:00
|
|
|
jsonlint src/data.json
|
2017-07-29 15:08:27 +02:00
|
|
|
|
|
|
|
|
2017-07-29 14:45:46 +02:00
|
|
|
# Create release dir and copy sources to that dir
|
2017-07-29 14:52:27 +02:00
|
|
|
echo "-> This release will be stored in $release_dir"
|
2017-07-29 14:45:46 +02:00
|
|
|
mkdir -p "$release_dir"
|
|
|
|
cp -ar src/* "$release_dir"
|
|
|
|
|
|
|
|
# Link this relase to $current
|
2017-07-29 14:52:27 +02:00
|
|
|
echo "-> Linking $dir/current to $release_dir"
|
|
|
|
rm "$dir/current" || true # This may fail
|
|
|
|
ln -sf "$dir/releases/$timestamp" "$dir/current"
|
|
|
|
|
|
|
|
echo "-> Deployed succesfully!"
|