-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromote.sh
executable file
·69 lines (51 loc) · 1.64 KB
/
promote.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -e
set -u
CMD=$1
MYSELF=$(basename "$0")
INT_API_IMG_ID="registry.heroku.com/digester-api-integration/web:latest"
INT_WORKER_IMG_ID="registry.heroku.com/digester-worker-integration/web:latest"
PROD_API_HEROKU_APP="digester-api-prod"
PROD_WORKER_HEROKU_APP="digester-worker-prod"
PROD_API_IMG_ID="registry.heroku.com/$PROD_API_HEROKU_APP/web:latest"
PROD_WORKER_IMG_ID="registry.heroku.com/$PROD_WORKER_HEROKU_APP/web:latest"
function promote_all() {
docker pull $INT_API_IMG_ID
docker pull $INT_WORKER_IMG_ID
local apiCreated;
local workerCreated;
apiCreated=$(docker image inspect $INT_API_IMG_ID | awk '/Created/{print $2}')
workerCreated=$(docker image inspect $INT_WORKER_IMG_ID | awk '/Created/{print $2}')
printf '\n++++ Images Pulled ++++\n'
printf 'Api created %s\n' "$apiCreated"
printf 'Worker created %s\n' "$workerCreated"
printf '\n'
read -p 'Promote? ' -n 1 -r
printf '\n'
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
docker tag $INT_API_IMG_ID $PROD_API_IMG_ID
docker tag $INT_WORKER_IMG_ID $PROD_WORKER_IMG_ID
printf 'Tagged both images\n'
docker push $PROD_API_IMG_ID
docker push $PROD_WORKER_IMG_ID
heroku container:release web --app $PROD_API_HEROKU_APP
heroku container:release web --app $PROD_WORKER_HEROKU_APP
}
function run_sanity_check() {
# update .bashrc
sed -i "s/^DIGESTER_PROMOTE_WORDLIST=.*/DIGESTER_PROMOTE_WORDLIST=\"all sanity\"/g" ~/.bashrc
echo "You might have to reload your .bashrc"
# check this script
shellcheck -x "$MYSELF"
}
case $CMD in
all) promote_all ;;
sanity) run_sanity_check ;;
*)
echo "unknown command.."
exit 1
;;
esac