Skip to content

Instantly share code, notes, and snippets.

@ramonornela
Created May 8, 2019 14:18
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 ramonornela/2e683e4fde6df66dca88972412dc52ef to your computer and use it in GitHub Desktop.
Save ramonornela/2e683e4fde6df66dca88972412dc52ef to your computer and use it in GitHub Desktop.
_set-env-vars-file:
steps:
- script:
inputs:
- title: "Set env vars file"
- content: |
#!/bin/bash
if [ -n "$ENV_FILE" ]; then
# specify local download path
file_local_path=$BITRISE_SOURCE_DIR/file_env
# download the file
wget -O "$file_local_path" "$ENV_FILE"
filename="$file_local_path"
# set vars define by env file in generic file storage
while IFS= read -r var
do
if [[ $var =~ "=" ]]; then
key=${var%%=*}
value=${var#*=}
valueDefault=${!key}
if [ -n "$value" ] && [ -z "$valueDefault" ]; then
echo "Set var: $key"
envman add --key $key --value $value
fi
fi
done < "$filename"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment