Skip to content

Commit

Permalink
chore:heroku env vars update script (#1334)
Browse files Browse the repository at this point in the history
* chore: script for updating env vars for a review app

* chore: add instructions to script
  • Loading branch information
1emu authored Oct 11, 2023
1 parent 1fbc8ac commit 89f2fdd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/.env.heroku
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SNAPSHOT_STATUS_ENABLED='true'
SNAPSHOT_STATUS_MAX_ERROR_BUFFER_SIZE=30
SNAPSHOT_STATUS_ERROR_RATE_THRESHOLD=0.33
25 changes: 25 additions & 0 deletions scripts/update-env-vars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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
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."

0 comments on commit 89f2fdd

Please sign in to comment.