aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2019-05-28 20:00:27 -0300
committerEuAndreh <eu@euandre.org>2019-05-28 20:01:52 -0300
commit6b6a2cee68c283be07a0b668262bb6472d77eb4e (patch)
tree3e879cabd3db1290ae62ad4004fbe3e10c6ae0f5
parentFix shell.nix path in nix-shell custom shebang (diff)
downloadserver-6b6a2cee68c283be07a0b668262bb6472d77eb4e.tar.gz
server-6b6a2cee68c283be07a0b668262bb6472d77eb4e.tar.xz
Store plan file in vps-state too
-rwxr-xr-xscripts/ci/provision.sh22
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/ci/provision.sh b/scripts/ci/provision.sh
index a89ffc5..4ae29e5 100755
--- a/scripts/ci/provision.sh
+++ b/scripts/ci/provision.sh
@@ -13,16 +13,30 @@ VPS_COMMIT_SHA="$(git rev-parse HEAD)" envsubst < ./scripts/box/run-backup-templ
ssh "$TLD" /home/vps/run-backup.sh
echo "Done."
-echo "Running 'terraform apply'..."
+echo "Running 'terraform plan' and storing the planfile..."
+# Terraform plan
terraform --version
terraform init
-terraform apply
+mkdir -p "../vps-state/secrets/plan-files/"
+PLAN_FILE="../vps-state/secrets/plan-files/$(date -Iseconds)-$(git rev-parse HEAD).tfplan"
+terraform plan -input=false -out="$PLAN_FILE"
+
+# Store on git repo
+pushd ../vps-state/
+git add "secrets/plan-files/$PLAN_FILE"
+git commit -m "CI: add .tfplan plan file for CI run $(git rev-parse HEAD)"
+git push origin master
+popd
+echo "Done."
+
+echo "Running 'terraform apply'..."
+terraform apply -input=false -auto-approve "$PLAN_FILE"
echo "Done."
-echo "Storing .tfstate file"
+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 commit -m "CI: update Terraform .tfstate files for CI run $(git rev-parse HEAD)"
git push origin master
popd
echo "Done."