aboutsummaryrefslogtreecommitdiff
path: root/provision.sh
blob: b13be57d85c5d04727c6df44ea753adc1ba45dfe (plain) (blame)
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
#!/usr/bin/env bash
set -Eeuo pipefail
cd "${BASH_SOURCE%/*}/"

echo "Unlocking git-crypt repositories and loading secrets..."
git crypt unlock
pushd ../vps-state/
git crypt unlock
popd
source .envrc
echo "Done.\n"

alias ssh="ssh -i secrets/id_rsa root@$TLD"

echo "Shutting down running containers..."
ssh "cd /home/vps/ && docker-compose down"
echo "Done.\n"

echo "Running `terraform apply`..."
terraform apply
echo "Done.\n"

echo "Storing .tfstate file"
pushd ../vps-state/
git add secrets/terraform.tfstate secrets/terraform.tfstate.backup
git commit -m "CI: update Terraform .tfstate files"
git push origin master
popd
echo "Done.\n"

echo "Locking git-crypt repositories back..."
git crypt lock
pushd ../vps-state/
git crypt lock
popd
echo "Done.\n"