From e8ba273b7a35d12456ab5be30d77510ebaa719c4 Mon Sep 17 00:00:00 2001 From: 1emu Date: Tue, 10 Oct 2023 12:59:20 -0300 Subject: [PATCH 1/2] chore: script for updating env vars for a review app --- scripts/.env.heroku | 3 +++ scripts/update-env-vars.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 scripts/.env.heroku create mode 100644 scripts/update-env-vars.sh diff --git a/scripts/.env.heroku b/scripts/.env.heroku new file mode 100644 index 000000000..368a66e90 --- /dev/null +++ b/scripts/.env.heroku @@ -0,0 +1,3 @@ +SNAPSHOT_STATUS_ENABLED='true' +SNAPSHOT_STATUS_MAX_ERROR_BUFFER_SIZE=30 +SNAPSHOT_STATUS_ERROR_RATE_THRESHOLD=0.33 diff --git a/scripts/update-env-vars.sh b/scripts/update-env-vars.sh new file mode 100644 index 000000000..840b5c611 --- /dev/null +++ b/scripts/update-env-vars.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +TARGET_APP=$1 + +if [[ -z "$TARGET_APP" ]]; then + echo "Missing app name" + exit 1 +fi + +EXISTING_VARS=$(heroku config --json --app=${TARGET_APP} | jq -r 'to_entries|map("\(.key)=\(.value)")|.[]') +NEW_VARS=$(awk -F= '/.+/ { print $1"="$2 }' ./.env.heroku) +MERGED_VARS=$(echo -e "${EXISTING_VARS}\n${NEW_VARS}") + +# Update env vars for the specified review app +echo "Updating env vars for ${TARGET_APP}..." +heroku config:set --app=${TARGET_APP} ${MERGED_VARS} +echo "Env vars updated for ${TARGET_APP}" + +echo "You're good." From d7e4f003ab18295e92abd9887439f6dc408a4194 Mon Sep 17 00:00:00 2001 From: 1emu Date: Tue, 10 Oct 2023 14:00:07 -0300 Subject: [PATCH 2/2] chore: add instructions to script --- scripts/update-env-vars.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/update-env-vars.sh b/scripts/update-env-vars.sh index 840b5c611..05f9d9efc 100644 --- a/scripts/update-env-vars.sh +++ b/scripts/update-env-vars.sh @@ -1,5 +1,11 @@ #!/bin/bash +# To run this script: +# - jq for parsing JSON (sudo apt-get install jq or brew install jq) +# - heroku CLI installed and authenticated +# - awk should already be on your system +# Put in the .env.heroku all the variables your want to add or overwrite to the review app + TARGET_APP=$1 if [[ -z "$TARGET_APP" ]]; then