-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·66 lines (51 loc) · 1.49 KB
/
deploy.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
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
readonly repo="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function main {
local -r ENV="$1"
local -r VERSION="$2"
local -r SERVICE="koodisto"
init_cloud_base_virtualenv
info "checking changes to cloud-environment repo"
pushd "$repo/../cloud-environment-$ENV"
git pull --rebase
popd
pushd "$repo/../cloud-base"
copy_mfa_token_to_clipboard
./aws/config.py "$ENV" publish
info "Checking currently running version"
info "./aws/deploy.py \"$ENV\" \"$SERVICE\" image"
./aws/deploy.py "$ENV" "$SERVICE" image
info "./aws/cloudformation.py \"$ENV\" services update -s \"$SERVICE\" --force"
./aws/cloudformation.py "$ENV" services update -s "$SERVICE" --force
info "Deploying version $VERSION to $ENV"
info "./aws/deploy.py \"$ENV\" \"$SERVICE\" deploy --version \"$VERSION\" --force"
./aws/deploy.py "$ENV" "$SERVICE" deploy --version "$VERSION" --force
popd
}
function init_cloud_base_virtualenv {
pushd "$repo/../cloud-base"
git pull --rebase
. oph-venv/bin/activate
pip install -r requirements.txt
popd
}
function copy_mfa_token_to_clipboard {
info "Copying MFA token to clipboard..."
op item get "AWS OPH" --otp | pbcopy
info "Copied!"
}
function info {
log "INFO" "$1"
}
function fatal {
log "ERROR" "$1"
exit 1
}
function log {
local -r level="$1"
local -r message="$2"
local -r timestamp=$(date +"%Y-%m-%d %H:%M:%S")
>&2 echo -e "${timestamp} ${level} ${message}"
}
main "$@"