Compare commits

...

5 Commits

Author SHA1 Message Date
Bryan Joshua Pedini 512b9c9c91 edited usage to show variables name
more clear usage for one-time override feature
2022-09-25 12:42:01 +02:00
Bryan Joshua Pedini 28705cabe3 added ability to one-time override the variables
by setting the variables externally at runtime when invoking the utility
2022-09-25 12:39:42 +02:00
Bryan Joshua Pedini ce7e2593f4 fixed bash less than in if statement 2022-09-20 09:49:23 +02:00
Bryan Joshua Pedini 0d7266ce35 added optional branch/tag checkout feature 2022-09-19 12:05:38 +02:00
Bryan Joshua Pedini ea0bea3c94 fixed home expansion in bash quotes, added brackets on $2
fuck you bash!
2022-09-18 18:13:21 +02:00
1 changed files with 27 additions and 15 deletions

View File

@ -1,29 +1,41 @@
#/usr/bin/env bash
set -e
# Check for the source server (with default)
DEPLOY_SOURCE_FILE="~/.deploy_source"
DEPLOY_SOURCE="https://git.bjphoster.com/deployments"
if [ -f "${DEPLOY_SOURCE_FILE}" ]; then
. "${DEPLOY_SOURCE_FILE}"
# Check if the source server variable has already been set externally
if [ -z "${DEPLOY_SOURCE}" ]; then
# Check for the source server (with default)
DEPLOY_SOURCE_FILE="${HOME}/.deploy_source"
DEPLOY_SOURCE="https://git.bjphoster.com/deployments"
if [ -f "${DEPLOY_SOURCE_FILE}" ]; then
. "${DEPLOY_SOURCE_FILE}"
fi
fi
# Check for the deploy position (with default)
DEPLOY_DESTINATION_FILE="~/.deploy_destination"
DEPLOY_DESTINATION="/opt"
if [ -f "${DEPLOY_DESTINATION_FILE}" ]; then
. "${DEPLOY_DESTINATION_FILE}"
# Check if the deploy position variable has already been set externally
if [ -z "${DEPLOY_DESTINATION}" ]; then
# Check for the deploy position (with default)
DEPLOY_DESTINATION_FILE="${HOME}/.deploy_destination"
DEPLOY_DESTINATION="/opt"
if [ -f "${DEPLOY_DESTINATION_FILE}" ]; then
. "${DEPLOY_DESTINATION_FILE}"
fi
fi
# Check if the correct usage is respected
if [ $# -ne 2 ]; then
echo "Usage: $0 <service> <service name>"
if [ $# -lt 2 ]; then
echo "Usage: $0 <service> <service name> [branch/tag]"
echo
echo "Current settings:"
echo "- Source · ${DEPLOY_SOURCE}"
echo "- Destination · ${DEPLOY_DESTINATION}"
echo "- \$DEPLOY_SOURCE · ${DEPLOY_SOURCE}"
echo "- \$DEPLOY_DESTINATION · ${DEPLOY_DESTINATION}"
exit
fi
echo "deploying ..."
git clone "${DEPLOY_SOURCE}/${1}" "${DEPLOY_DESTINATION}/$2"
git clone "${DEPLOY_SOURCE}/${1}" "${DEPLOY_DESTINATION}/${2}"
if [ $# -eq 3 ]; then
pushd "${DEPLOY_DESTINATION}/${2}"
git checkout "${3}"
popd
fi