Skip to content

Instantly share code, notes, and snippets.

@itcherry
Created June 24, 2021 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itcherry/0ed5ba7a2035e354e58a89f57a02e03f to your computer and use it in GitHub Desktop.
Save itcherry/0ed5ba7a2035e354e58a89f57a02e03f to your computer and use it in GitHub Desktop.
React environment variables generator from local gradle.properties file
#!/bin/bash
PROPERTY_FILE=~/.gradle/gradle.properties
function getProperty {
PROP_KEY=$1
PROP_VALUE=`cat $PROPERTY_FILE | grep -w "$PROP_KEY" | cut -d'=' -f2`
echo $PROP_VALUE
}
if [ $1 == 'stage' ]
then
read -d '' env << EOF
API_BASE=/new/api
SOME_YOUR_KEY=$(getProperty "YOUR_KEY_STAGE")
# Insert your others key here as well
EOF
elif [ $1 == 'prod' ]
then
read -d '' env << EOF
API_BASE=/new/api
SOME_YOUR_KEY=$(getProperty "YOUR_KEY_PROD")
EOF
fi
echo "$env" > ../../../RELATIVE_PATH_TO_REACT_NATIVE_PROJECT/.env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment