forked from MuckRock/squarelet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostdeploy.sh
More file actions
executable file
·19 lines (17 loc) · 807 Bytes
/
postdeploy.sh
File metadata and controls
executable file
·19 lines (17 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Check that the script is running in a Heroku review app.
#
# This is inferred from the presence of a HEROKU_APP_NAME environment variable,
# which is automatically injected by Heroku into review apps.
#
# By checking that we're in a "staging" environment, we have confidence that we're
# only copying staging data into an environment that expects to receive it.
set -e
if [ -n "$HEROKU_APP_NAME" ] && [ "$DJANGO_ENV" = "staging" ]; then
LATEST_BACKUP=$(heroku pg:backups --app squarelet-staging | awk '/b[0-9]+/ {print $1; exit}')
heroku pg:backups:restore "squarelet-staging::$LATEST_BACKUP" DATABASE_URL \
--app "$HEROKU_APP_NAME" \
--confirm "$HEROKU_APP_NAME"
fi
# No matter what environment we're in, ensure we run any Django migrations.
python manage.py migrate --noinput