Skip to content

Commit 43c51b1

Browse files
authored
Update replace-variables.sh to adapt changes in #118
1 parent f6f65a0 commit 43c51b1

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

deployment/replace-variables.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -e
23

34
echo "Baking Environment Variables..."
45

@@ -7,10 +8,26 @@ if [ -z "${NEXT_PUBLIC_API_URI}" ]; then
78
exit 1
89
fi
910

10-
# Find and replace baked values with real values for the API_URI
11-
find /app/packages/dashboard/public /app/packages/dashboard/.next -type f -name "*.js" |
12-
while read file; do
13-
sed -i "s|PLUNK_API_URI|${NEXT_PUBLIC_API_URI}|g" "$file"
11+
if [ -z "${NEXT_PUBLIC_AWS_REGION}" ]; then
12+
echo "NEXT_PUBLIC_AWS_REGION is not set. Exiting..."
13+
exit 1
14+
fi
15+
16+
# Process each directory that might contain JS files
17+
for dir in "/app/packages/dashboard/public" "/app/packages/dashboard/.next"; do
18+
if [ -d "$dir" ]; then
19+
# Find all JS files and process them
20+
find "$dir" -type f -name "*.js" -o -name "*.mjs" | while read -r file; do
21+
if [ -f "$file" ]; then
22+
# Replace environment variables
23+
sed -i "s|PLUNK_API_URI|${NEXT_PUBLIC_API_URI}|g" "$file"
24+
sed -i "s|PLUNK_AWS_REGION|${NEXT_PUBLIC_AWS_REGION}|g" "$file"
25+
echo "Processed: $file"
26+
fi
27+
done
28+
else
29+
echo "Warning: Directory $dir does not exist, skipping..."
30+
fi
1431
done
1532

1633
echo "Environment Variables Baked."

0 commit comments

Comments
 (0)