-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.envrc
More file actions
39 lines (32 loc) · 1.3 KB
/
.envrc
File metadata and controls
39 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
# Load all variables from .env file
if [ -n "$DATA_ENGINEERING_DOT_FILE_PATH" ] && [ -f "$DATA_ENGINEERING_DOT_FILE_PATH" ]; then
dotenv "$DATA_ENGINEERING_DOT_FILE_PATH"
watch_file "$DATA_ENGINEERING_DOT_FILE_PATH"
elif [ -f .env ]; then
dotenv .env
watch_file .env
fi
export PROJECT_ROOT_PATH="$PWD"
# Activate Python virtual environment if it exists
if [ -d .venv ]; then
source_env .venv/bin/activate
export VIRTUAL_ENV="$PWD/.venv"
PATH_add .venv/bin
fi
# Convert relative paths to absolute paths based on values from .env
export PRODUCT_METADATA_REPO_PATH="$PWD/${PRODUCT_METADATA_REPO_PATH#./}"
export TEMPLATE_DIR="$PWD/${TEMPLATE_DIR#./}"
# make the binaries available on your path
PATH_add bash/bin
# Set BUILD_ENGINE_SCHEMA to branch name if not on main
# Watch for branch changes
watch_file .git/HEAD
CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
if [ -n "$CURRENT_BRANCH" ] && [ "$CURRENT_BRANCH" != "main" ]; then
# Convert to lowercase and replace dashes with underscores
export BUILD_ENGINE_SCHEMA=$(echo "$CURRENT_BRANCH" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
else # On main branch
unset BUILD_ENGINE_SCHEMA
fi
export BUILD_ENGINE_SERVER=postgresql://$BUILD_ENGINE_USER:$BUILD_ENGINE_PASSWORD@$BUILD_ENGINE_HOST:$BUILD_ENGINE_PORT