Skip to content

Commit

Permalink
Update replace-variables.sh to adapt changes in #118
Browse files Browse the repository at this point in the history
  • Loading branch information
emreloper authored Dec 1, 2024
1 parent f6f65a0 commit 43c51b1
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions deployment/replace-variables.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

echo "Baking Environment Variables..."

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

# Find and replace baked values with real values for the API_URI
find /app/packages/dashboard/public /app/packages/dashboard/.next -type f -name "*.js" |
while read file; do
sed -i "s|PLUNK_API_URI|${NEXT_PUBLIC_API_URI}|g" "$file"
if [ -z "${NEXT_PUBLIC_AWS_REGION}" ]; then
echo "NEXT_PUBLIC_AWS_REGION is not set. Exiting..."
exit 1
fi

# Process each directory that might contain JS files
for dir in "/app/packages/dashboard/public" "/app/packages/dashboard/.next"; do
if [ -d "$dir" ]; then
# Find all JS files and process them
find "$dir" -type f -name "*.js" -o -name "*.mjs" | while read -r file; do
if [ -f "$file" ]; then
# Replace environment variables
sed -i "s|PLUNK_API_URI|${NEXT_PUBLIC_API_URI}|g" "$file"
sed -i "s|PLUNK_AWS_REGION|${NEXT_PUBLIC_AWS_REGION}|g" "$file"
echo "Processed: $file"
fi
done
else
echo "Warning: Directory $dir does not exist, skipping..."
fi
done

echo "Environment Variables Baked."

0 comments on commit 43c51b1

Please sign in to comment.