Skip to content

Instantly share code, notes, and snippets.

@santospatrick
Last active May 14, 2024 17:48
Show Gist options
  • Save santospatrick/ae0b35bad76b42b95c5c051750e64f9f to your computer and use it in GitHub Desktop.
Save santospatrick/ae0b35bad76b42b95c5c051750e64f9f to your computer and use it in GitHub Desktop.
Set heroku env variables programmatically
chmod +x set_heroku_env.sh
./set_heroku_env.sh
#!/bin/bash
# Check if .env.local file exists
if [ ! -f .env.local ]; then
echo "Error: .env.local file not found"
exit 1
fi
# Read variables from .env.local file and set them as Heroku environment variables
while IFS='=' read -r key value; do
# Skip lines starting with #
if [[ ! -z "$key" && ! -z "$value" && "${key:0:1}" != "#" ]]; then
heroku config:set "$key"="$value" --app your-app-name
fi
done < .env.local
echo "Heroku environment variables set successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment