diff --git a/scripts/deploy_remote.sh b/scripts/deploy_remote.sh index 772386d..de2e258 100755 --- a/scripts/deploy_remote.sh +++ b/scripts/deploy_remote.sh @@ -31,11 +31,38 @@ if [[ -n "$env_file" ]]; then cp "$env_file" .env fi +load_env_file() { + local env_path="$1" + local line="" + local key="" + local value="" + + while IFS= read -r line || [[ -n "$line" ]]; do + line="${line%$'\r'}" + + if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then + continue + fi + + key="${line%%=*}" + value="${line#*=}" + + key="$(printf '%s' "$key" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')" + + if [[ -z "$key" ]]; then + continue + fi + + if [[ "$value" =~ ^\'.*\'$ || "$value" =~ ^\".*\"$ ]]; then + value="${value:1:${#value}-2}" + fi + + export "$key=$value" + done < "$env_path" +} + if [[ -f .env ]]; then - set -a - # shellcheck disable=SC1091 - source .env - set +a + load_env_file .env fi mkdir -p \