2022-02-13 19:40:00 +01:00
|
|
|
#!/bin/bash
|
2018-05-24 11:43:34 +02:00
|
|
|
|
2018-08-02 00:09:29 +02:00
|
|
|
# Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr>
|
|
|
|
# License: GNU AGPL-3+ (see full text in LICENSE file)
|
|
|
|
|
2018-05-24 11:43:34 +02:00
|
|
|
set -e
|
|
|
|
[ -n "$DEBUG" ] && set -x
|
|
|
|
|
|
|
|
# git name-rev is fail
|
2022-02-13 19:40:00 +01:00
|
|
|
CURRENT=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
TIMESTAMP=$(date +"%s")
|
2018-05-24 11:43:34 +02:00
|
|
|
|
|
|
|
echo "👀 Fetching git repository information…"
|
|
|
|
git fetch origin --quiet
|
|
|
|
|
2022-02-13 19:40:00 +01:00
|
|
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
CURRENT_HEAD=$(git rev-parse HEAD)
|
|
|
|
ORIGIN_HEAD=$(git rev-parse origin/master)
|
2018-05-24 11:43:34 +02:00
|
|
|
|
|
|
|
if [ "master" != "${CURRENT_BRANCH}" ]; then
|
|
|
|
echo "😕 Only master can be deployed to production"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-02-13 19:40:00 +01:00
|
|
|
if [ "${CURRENT_HEAD}" != "${ORIGIN_HEAD}" ]; then
|
2018-05-24 11:43:34 +02:00
|
|
|
echo "😕 Local master is not up to date with origin"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
read -p "👉 Deploy master to production ? (y/N) " confirmed
|
|
|
|
|
|
|
|
if [ "${confirmed}" != "y" ]; then
|
|
|
|
echo "😞 Abort, bye."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-08-25 17:36:36 +02:00
|
|
|
echo "🚀 Deploying master to production !"
|
2018-05-24 11:43:34 +02:00
|
|
|
bundle exec cap production deploy
|
|
|
|
|
|
|
|
echo "😎 Done !"
|