Skip to content

Instantly share code, notes, and snippets.

@epmartini
Created May 14, 2018 11:15
Show Gist options
  • Save epmartini/91d94c1432c42ef2809614f1e325856c to your computer and use it in GitHub Desktop.
Save epmartini/91d94c1432c42ef2809614f1e325856c to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This script set the heroku environment variables
#
# @author Patrick Martini <patrick.martini@emarsys.com>
# Exit immediately on error
set -e
# Detect whether output is piped or not.
[[ -t 1 ]] && piped=0 || piped=1
version="v0.1"
# Print usage
usage() { cat <<HEREDOC
$(basename $0) <ENV_FILES> <HEROKU APP>
Set the heroku environment variables
Examples:
$(basename $0) heroku_environment_variables.txt ems-preventive-checks-staging"
HEREDOC
}
# Print help if no arguments were passed.
[[ $# -eq 0 ]] && usage && exit 1;
file=$1
app=$2
echo "$app"
[ -z "$file" ] && err "Missing file" >&2 && exit 1;
[ -z "$app" ] && err "Missing app" >&2 && exit 1;
envs=""
while IFS='=' read -r key value
do
envs="$envs ${key}='${value}'"
done < "$file"
eval "heroku config:set $envs --app $app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment