#/usr/bin/env bash set -e # 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 # 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 # Check if the correct usage is respected if [ $# -lt 2 ]; then echo "Usage: $0 [branch/tag]" echo echo "Current settings:" echo "- Source · ${DEPLOY_SOURCE}" echo "- Destination · ${DEPLOY_DESTINATION}" exit fi echo "deploying ..." git clone "${DEPLOY_SOURCE}/${1}" "${DEPLOY_DESTINATION}/${2}" if [ $# -eq 3 ]; then pushd "${DEPLOY_DESTINATION}/${2}" git checkout "${3}" popd fi